Is there any default way to model something like the following
situation in ActiveRecord?:
A company has_many :buildings which are associated to :company, e.g.
in a polymorphic way.
Moreover one and only one of the buildings is the company’s
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 two flags.
Is there any way to map that to ActiveRecord?