-
Type: Improvement
-
Resolution: Won't Fix
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
I have the following model structure: a page embeds_one Banner that embeds_many Slides and each Slide embeds_many contents
class Page include Mongoid::Document embeds_one :banner accepts_nested_attributes_for :banner, allow_destroy: true end class Banner include Mongoid::Document embedded_in :page embeds_many :slides accepts_nested_attributes_for :slides, allow_destroy: true end class Slide include Mongoid::Document embedded_in :banner embeds_many :contents accepts_nested_attributes_for :contents, allow_destroy: true end class Content include Mongoid::Document embedded_in :slide field :value, type: String end
and I am starting with a banner that has one slide with some contents. Now I send a JSON request to the server to add new contents to the existing slide and create new slide with its contents; something like
'page' => { '_id' => '1', 'banner_attributes' => { '_id' => '123', 'slides_attributes' => [ { '_id' => '1', 'contents_attributes' => [ { '_id' => '1', 'value' => 'some persisted value' }, { 'value' => 'new content here, there is no _id yet' } ] }, { 'contents_attributes' => [ { 'value' => 'new content in a newly created slide' } ] } ] } }
Now calling page.update page_params give me some very strange error:
Moped::Errors::OperationFailure (The operation: #<Moped::Protocol::Command @length=87 @request_id=594 @response_to=0 @op_code=2004 @flags=[] @full_collection_name="web_builder_development.$cmd" @skip=0 @limit=-1 @selector={:getlasterror=>1, :w=>1} @fields=nil> failed with error 16837: "Cannot update 'banner.slides.0.contents' and 'banner.slides' at the same time"
while this is a self-explanatory error:
> failed with error 16837: "Cannot update 'banner.slides.0.contents' and 'banner.slides' at the same time"
but I should be allowed to create new slides and add new contents to existing slides at once
- is duplicated by
-
MONGOID-2989 Conflicting or missing modifications when updating using nested attributes
- Closed
- is related to
-
MONGOID-2989 Conflicting or missing modifications when updating using nested attributes
- Closed
-
MONGOID-3059 Bug in accept_nested_attributes with two levels deep
- Closed
-
MONGOID-4149 Complex document updates can fail with op conflict
- Closed
- related to
-
SERVER-11285 $set issue: have conflicting mods in update
- Closed