-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 5.1.4
-
Component/s: None
-
None
-
Environment:Linux Mint 17.3
Mongoid 5.1.4
Mongodb 2.6.12
When embed document have presence validation for parent document - it creates doubles on save.
Example:
class Person include Mongoid::Document field :name, type: String embeds_many :addresses end class Address include Mongoid::Document field :address, type: String embedded_in :person validates :person, presence: true end p = Person.create!(name: 'Person') p.addresses.build(address: '1') p.addresses.build(address: '2') p.addresses = p.addresses p.save!
After save there are 3 addresses for person - 2 copies for the second one with same ObjectID
- is duplicated by
-
MONGOID-3809 Duplicate embedded document created on save (repro included)
- Closed