ruby on rails - Is a migration necessary for generating an ID in a has_many/belongs_to relationship? -


i have rails app 2 related classes. pet has_many toys, , toy belongs_to pet.

in order have index of toys pets (meaning every toy want have index identifier stating pet belongs to), need add migration adding pet_id column each toy (to toys table), or automatically done rails has_many-belongs_to relationship?

you need add pet_id column toys table if table doesn't have one. has_many , belongs_to create methods ease writing code.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -