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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -