Displaying 1 result from an estimated 1 matches for "head_quarter_id".
2009 Jan 18
5
Modeling complex associations
...er one and only one of the buildings is the company''s
headquarter.
Thinking in terms of the database, I''d prefer to add an owning
association, an thus have a has_many :buildings plus a
has_one :headquarter, :class => "Building" assocation, where the
foreign key "head_quarter_id" should be assigned to the company and
refer to the buildings table.
I''d prefer that to tagging one building with a headquarter-flag
because there''s the advantage of only being forced to change one
dataset (the company, more exactly its headquarter_id), instead of
changing tw...