Track owners and pets!
Practice:
- one-to-many associations
- validations and error handling
- Fork this repo, and clone it onto your local machine. Change directories into the project directory.
- Add the class copy of this repo as a new remote:
git remote add upstream https://github.com/sf-wdi-labs/rails-pet-lab
so that you can easily get any updates from the class copy if needed. - Run
bundle update
thenbundle install
in the Terminal to update and install gems from the Gemfile. (Feel free to take a look at what's included, first.) - Run
rails db:create db:migrate
in the Terminal to create your local database and run the migrations. - Run
rails s
in the Terminal to start your server. - Navigate to
localhost:3000
in the browser - you should see a genericsite#index
page. - Run
rails routes
to see what routes are available in the app. - Run
rails notes
to see some of the things you'll do with this app
In this part, you'll:
-
Change the
Owner
andPet
models so that each owner has many pets, and each pet belongs to one owner. -
Add a foreign key to the
pets
table so that each pet stores a reference to its owner.
And more!
In this part, you'll:
-
Generate a model for
Appointment
s. -
Set up the
Pet
andAppointment
models so each appointment belongs to one pet and each pet can have many appointments. -
Give the
appointments
table a foreign key to reference a pet.
And more!
In this part, you'll:
-
See an alternate way to use
has_many through:
for creating a "shortcut" instead of a many-to-many association. -
Add a new association between the
Owner
andAppointment
models so that an owner has many appointments through their pets.
And more!
In this optional section, you could try one of the following tasks:
-
Navigation: practice using path helper methods by adding
link_to
s to help users move among the pages of your site. -
Full CRUD: Create or fill in routes, controllers, and views for the missing crud actions for owners, pets, and/or appointments.
-
Model Methods: Practice your Ruby skills, and get more time with the
Date
andDateTime
built-in classes by creating custom model methods.
In this part, you'll:
-
Add validations to owners to pass tests.
-
Use flash messages to tell users what's wrong if owner creation fails.
-
Use TDD for pet validations - write tests to make sure the model requires a name and breed. Then write code to pass your tests.
And more!