On Nov 1, 2:18 pm, dpal <dan...@gmail.com> wrote:
> Unfortunatelly has_one polymorphic is not supported, therefore we need
> to think in reverse.
That's because if the "belongs_to" is on the company models, it's no
longer a polymorphic relationship. At that point it's just a regular
one-to-one relationship, like the following example. Each of the
companies has a foreign key to Person.
class RealStateCompany
belongs_to :user
end
class ConstructionCompany
belongs_to :user
end
class NaturalPerson
belongs_to :user
end
class User
has_one :real_state_company
has_one :construction_company
has_one :natural_person
end
This works. Reversing the relationship also works. Just depends on how
you want to design it and where you want the foreign keys.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment