To Examples

Depot1 Example

Directions

  1. Create a new Rails project named Depot1.
  2. Generate a Rails scaffold named Product with these fields.
    Field Datatype
    cat_num string
    title string
    description text
    image_url string
    price string
  3. Generate a Rails scaffold named Customer with these fields.
    Field Datatype
    last_name string
    first_name string
    address string
    cc_type string
    cc_num integer
    cc_exp date
  4. Generate a Rails scaffold named ShoppingCart with these fields.
    Field Datatype
    customer_id integer
  5. Generate a Rails scaffold named LineItem with these fields.
    Field Datatype
    customer_id integer
    product_id integer
    quantity integer
  6. Source code for the seed file Depot1/db/seed.rb.
  7. View the index pages of the Doctor and Patient index pages with these URLs:
    http://localhost:3000/doctors
    http://localhost:3000/patients
    
  8. Set up the one-to-many relationships:
    # Although only one shopping cart should be active,
    # there may be many checked out and closed ones.
    
    # Product model:
    has_many :line_items
    
    # Customer model:
    has_many :shopping_carts
    
    # ShoppingCart model:
    belongs_to :customer
    has_many :line_items
    
    # LineItem model:
    belongs_to :shopping_cart
    belongs_to :customer
    
  9. Modify the layout and styles for the Product controller:
    1. Use this stylesheet: Depot1/app/assets/stylesheets/products.scss