Mongoid, how to keep relations in sync for common parent model?
I have three models:
Agency
has_many :owners
has_many :properties
Owner
belongs_to :agency
has_many :properties
Property
belongs_to :owner
belongs_to :agency
The agency.properties relation should refer to all properties that all
owners have, but when I create a property inside an owner, the
agency.properties relation is not created. I want this relation to be
automatically fulfilled, as well as deleted when the owner or the property
is deleted.
How can I achieve this behavior with mongoid?
No comments:
Post a Comment