I have a table Owners, and Pets. Each Owner has_many pets, and each pet belong_to owner. I’m writing a function that creates a new pet by taking in the owner_id and the pet information. So far I have
pet = Pet.new(pet_hash)
pet.save
But how do I associate that Pet with the owner_id?
Assuming you have the owner, you can do something like: