-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
class Foo include Mongoid::Document has_many :bars end class Bar include Mongoid::Document belongs_to :foo end f = Foo.create! => #<Foo _id: 4ef07b860bed3f9672000001, _type: nil> Bar.create! :foo => f Mongo::OperationFailure: 11000: E11000 duplicate key error index: blah_development.bars.$_id_ dup key: { : ObjectId('4ef07b8a0bed3f9672000002') }
When Mongoid tries to persist the Bar object, it ends up doing the insert twice, breaking the unique index on _id. This is with mongoid v2.3.4, driver v1.5.2.