On Mar 12, 6:05 am, neerolyte neerol...@gmail.com wrote:
I've looked at a bunch of tutorials and don't really understand what
is supposed to happen after I add an association (belongs_to, has_many
etc) to both sides of a relationship.
A lot of the tutorials just add the associations and
Does that mean I have to write a custom migration for it, the only
automated migrations I can find are for adding/removing columns
(AddXXXtoYYY).
Is there something like AddHasAndBelongsToManyModelXToModelY?
Dave.
2009/3/12 Frederick Cheung frederick.che...@gmail.com:
On Mar 12, 6:05 am,
I dont think so you need to do any thing manually with the db..
Just use the association by using dot operator.
Regards
Rabia
On Thu, Mar 12, 2009 at 11:05 AM, neerolyte neerol...@gmail.com wrote:
I've looked at a bunch of tutorials and don't really understand what
is supposed to happen after
The associations you create in a model have to be backed up by the
appropriate fields in the DB.
For example:
class Person
has_many :addresses
class Address
belongs_to :person
should be a model representation of the relationship inherent in the
database (the two really go hand-in-hand).
So building on that example, you should add a column person_id to the
address table. Rails will infer the foreign key based on rails model
names. U can also specify the actual column by passing :foreign_key
into belongs_to macro.
Roman
On Mar 12, 6:22 am, Ar Chron
5 matches
Mail list logo