Hi, 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 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 two flags. Is there any way to map that to ActiveRecord? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

