A local pet shelter has tapped you to build their database and connect it with Active Record.
run bundle install
Create your migrations.
-
Shelters
should have aname
and anaddress
-
Pets
should have aname
, anage_in_years
, aspecies
, a boolean foradopted?
, ashelter_id
, and aadopter_id
-
Adopters
should have afirst_name
and alast_name
Column | Type |
---|---|
name | string |
address | string |
Column | Type |
---|---|
name | string |
age | integer |
species | string |
adopted? | boolean |
shelter_id | integer |
adopter_id | integer |
Column | Type |
---|---|
first_name | string |
last_name | string |
- What associations will this need?
- (i.e.
has_many
,has_many through
, andbelongs_to
)
Shelter#pets
returns all pets associated with the shelterShelter#adopters
returns all the people who have adopted from this shelterShelter#current_pets
returns only the pets associated with the shelter who haven't been adoptedShelter#adopted_pets
returns only the pets associated with the shelter who have been adopted
Pet#shelter
returns an instance of the shelter that pet is associated withPet#adopter
returns an instance of the person who adopted the pet, if anyPet.oldest
returns the oldest pet by agePet.average_age
returns the average age of all petsPet#in_dog_years
returns the age in dog years of a pet if their species isdog
(one human year is roughly five dog years and yes I know this is a gross oversimplification)
Adopter#pets
returns all pets adopted by this personAdopter#shelters
returns every shelter the person has adopted fromAdopter#full_name
returns the adopter's combined first and last namesAdopter#adopt(pet)
takes in an instance of aPet
, changes the pet'sadopted?
status to true, and associates the pet with the adopter if they're not already adoptedAdopter#fav_pet
returns the type of pet (species) they've adopted most of ornil
if they've adopted no pets
Even older pets need love!