Three types of stretch challenges lay before you. Pick and implement any set(s) you find interesting.
Practice using path helper methods by adding link_to
s to help users move among the pages of your site. Consider adding:
- a link to the owner index from the owner show page
- a link to the owner's show page from the list of their pets
- a link to the owner's list of pets from the pet show page
- a link to the site index on every page (keep it DRY!)
Create or fill in routes, controllers, and views for the missing crud actions for owners and pets. Choose one route at a time. It might be easiest to start with destroy
; just remember the difference between destroy
and delete
!
Practice your Ruby skills - and get more time with the Date
and DateTime
built-in classes.
-
Generate and run a migration to add a
date_of_birth
field to thePet
model. The type of this field should bedate
. Display the pet'sdate_of_birth
in the view forpets#show
. -
Fill in the
Pet
model'sdate_of_birth_cannot_be_in_the_future
method. This method should add an error to the validation errors if the pet'sdate_of_birth
is in the future. See the Validations Rails guide. -
Fill in the
Pet
model'sage
instance method. If the pet instance has adate_of_birth
, this method should calculate and return the pet's age in years (as a decimal). If the pet doesn't have adate_of_birth
, theage
method should returnnil
. Display the pet'sage
in the view forpets#show
.