To Lecture Notes

IT 232 -- 10/21/15

  1. What is a Rails action?
    Ans: It is a method in the controller. Usually this method is executed on behalf of a view, which is displayed after the action is executed. Sometimes an action is executed, and then redirected to a different action.
  2. What is ActiveRecord?
    Ans: It is a ORM (Object Relational Mapping) that sits on top of SQL. ActiveRecord methods allow one to extract data from a database.
  3. What are some ActiveRecord methods?
    Ans: all, first, last, where, order.
  4. What is the difference between an array of model objects and an ActiveRecord relation?
    Ans: An ActiveRecord relation is a series of method calls that contain selected or transformed data from a database. Before this relation can be used, it must be changed into an array with the new, first, or last methods.
  5. How do you know whether to use collection or member in config/routes.rb when adding a view to a scaffold-based project?
    Ans: Use member if the action applies to a specific id (row in the database). An example is the show view. Use collection when the action applies to all of the rows in the database, for example the index view.
  6. Create a Rails scaffold-based project.
    1. Add models Doctor and Patient as in the Hospital Examples.
    2. Populate the doctors and patients tables with the seeds.rb file from the Hospital Examples.
    3. Add a page named directory that lists all of the doctors with their patients. Use nested unordered lists. Both the doctors should be displayed in alphabetical order. Also display unordered lists of the female and male patients separately, showing the doctor name for each patient.
    Ans: See the Hospital3 Example.

Designating a Root Page

The Depot1 Example

FormHelper Methods

Simple Rails Authentication