class Person
include Mongoid::Document
field :name
embeds_many :addresses
end
class Company
include Mongoid::Document
field :name
embeds_many :addresses
end
class Address
include Mongoid::Document
embedded_in :addressable, inverse_of :addresses
end
I tried something like this
company = Company.first
person = Person.first
address = Address.new
company.addresses << address
company.save
=>true
person.addresses << address
person.save
=>true
But I didn't found address embedded in person.But I found that it was embedded in company. Did anyone know why? Or Can't I embed address in multiple document.
Again while I reversed like this
person.addresses << address
person.save
=>true
company.addresses << address
company.save
=>true
I found address was embedded in person not in company.. Any Ideas.