To Examples

PetSalon Directions

 

  1. Create a new Rails project named PetSalon.
     
  2. Navigate to the PetSalon folder.
     
  3. Upload some or all of these pet photos to /app/assets/images.
     

  4. Create a Rails scaffold controller with model name Owner. You choose the fields for Owner. For example, you could choose these fields:
     
    Field Datatype
    name string
    phone string
    address string

     
  5. Create a Rails scaffold controller with model name Pet. Two of the field names for Pet must be pet_image and owner_id (foreign key). You choose the other fields for Pet. For example, you could choose these fields: fields:
     
    Field Datatype
    name string
    animal_type string
    birth_date date
    pet_image string
    owner_id integer

     
  6. Start the Rails server. Use these URLs for viewing the index view of the Owners and Pets controllers:
  7. Set up a one-to-many relationship between Owner and Pet by placing this line in the Owner class in apps/models/owner.rb
    and by placing this line in the Pet class in apps/models/pet.rb
  8. Set up some validations for your project including ones that
     

  9. In the index and show views for the Pets controller, display the image of each animal by replacing the code
    with
  10. Replace the owner_id field in /app/views/pet/_form.html.erb with a dropdown box that displays the choices for owner's names.
     
  11. Add a field in the Pets index view that shows the pet count for each owner.
     
  12. Add a new controller named Home with views welcome and show. The welcome view introduces Geri's Pet Salon and the show_count view that displays the current count of each animal type.
     
  13. Place hyperlinks on the welcome page and the show view and to the Owners and Pets controllers: