Skip to content

SF-WDI-LABS/rails-pet-lab

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pet App!

Overview

Track owners and pets!

Objectives

Practice:

  • one-to-many associations
  • validations and error handling

Getting Started

  1. Fork this repo, and clone it onto your local machine. Change directories into the project directory.
  2. 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.
  3. Run bundle update then bundle install in the Terminal to update and install gems from the Gemfile. (Feel free to take a look at what's included, first.)
  4. Run rails db:create db:migrate in the Terminal to create your local database and run the migrations.
  5. Run rails s in the Terminal to start your server.
  6. Navigate to localhost:3000 in the browser - you should see a generic site#index page.
  7. Run rails routes to see what routes are available in the app.
  8. Run rails notes to see some of the things you'll do with this app

owner-pet-erd

In this part, you'll:

  • Change the Owner and Pet 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!

owner-pet-appointment-erd

In this part, you'll:

  • Generate a model for Appointments.

  • Set up the Pet and Appointment 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!

has-many-through

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 and Appointment 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_tos 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 and DateTime 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!

About

Starter code and challenges for validations & error-handling in Rails

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 79.6%
  • HTML 15.0%
  • CSS 2.6%
  • JavaScript 1.4%
  • CoffeeScript 1.4%