-
Notifications
You must be signed in to change notification settings - Fork 506
Mongoid _destroy is not deleted embedded document using nested_form gem #117
Comments
I use nested_form with Mongoid 2.4.5 and Rails 3.2 and works like a charm. |
I have the same issue as well. The pullAll query's criteria contains other fields in the condition. I think that is causing the pullall to fail Parameters: {"utf8"=>"✓", "authenticity_token"=>"iShSOBXpgNBEkD+xZ/oN7SazILyV7EVHWxhogMWZHzE=", "activity"=>{"name"=>"test", "description"=>"test", "status"=>"active", "activity_photos_attributes"=>{"0"=>{"_destroy"=>"1", "id"=>"4f4ff1d9c1119408d6000012"}, "1"=>{"_destroy"=>"1", "id"=>"4f4ff1d9c1119408d6000013"}, "2"=>{"_destroy"=>"1", "id"=>"4f4ff1d9c1119408d6000014"}, "3"=>{"_destroy"=>"1", "id"=>"4f4ff1d9c1119408d6000015"}}}, "commit"=>"Update Activity", "vendor_id"=>"4f4c732cc11194ad4e00001a", "id"=>"4f4ff1d9c1119408d6000011"} MONGODB ninjatravelco_development['activities'].update({"_id"=>BSON::ObjectId('4f4ff1d9c1119408d6000011')}, {"$pullAll"=>{"activity_photos"=>[{"_id"=>BSON::ObjectId('4f4ff1d9c1119408d6000012'), "_type"=>"ActivityPhoto", "asset_file_name"=>nil, "asset_content_type"=>nil, "asset_file_size"=>nil, "asset_updated_at"=>nil, "processing"=>false}, {"_id"=>BSON::ObjectId('4f4ff1d9c1119408d6000013'), "_type"=>"ActivityPhoto", "asset_file_name"=>nil, "asset_content_type"=>nil, "asset_file_size"=>nil, "asset_updated_at"=>nil, "processing"=>false}, {"_id"=>BSON::ObjectId('4f4ff1d9c1119408d6000014'), "_type"=>"ActivityPhoto", "asset_file_name"=>nil, "asset_content_type"=>nil, "asset_file_size"=>nil, "asset_updated_at"=>nil, "processing"=>false}, {"_id"=>BSON::ObjectId('4f4ff1d9c1119408d6000015'), "_type"=>"ActivityPhoto", "asset_file_name"=>nil, "asset_content_type"=>nil, "asset_file_size"=>nil, "asset_updated_at"=>nil, "processing"=>false}]}}) |
8 months later, still no solution on this issue for rails 3.1? |
Could you please push a test application reproducing this issue? Thanks. |
I'm afraid even 3 years after this is still a problem... If you're still reading, would you mind posting your solution in case you've found any ? |
Rails 4.1.8 works when using (not without
|
Thanks. I did a big update to Rails 4.2 and it fixed it. |
I still encounter problems with either I have found different behavior of In short, But Conclusion: It's mongoid issue. |
i use mongoid (4.0.2) and rails 4.2, it can not work too! |
@ales-vilchytski Correct! I had the same issues with _destroy in accepts_nested_attributes_for |
same issue also with embedded_many relation |
I am on Rails 3.1, Mongoid 2.3.3, and using the nested_form gem. In my form, I have the nested_form link_to_add and link_to_remove set up to add and remove an embedded document in my model. The link_to_add helper method works great, but the link_to_remove help method changes are not persisted in MongoDB. In the rails output, I can see the JSON parameter passed to Mongoid has the _destroy: 1 value set but the change is not saved to MongoDB.
Here is the model
Here is the params:
"photos_attributes"=>{"0"=>{"_destroy"=>"1", "data_cache"=>"", "id"=>"4ec48e8e6985605b5d000073"}, "1"=>{"_destroy"=>"1", "data_cache"=>"", "id"=>"4ec48e8e6985605b5d000074"}, "2"=>{"_destroy"=>"false", "data_cache"=>"", "id"=>"4ec4925a6985605b5d000083"}, "3"=>{"data_cache"=>"", "_destroy"=>"false"}
I'm sure I missed something, but I haven't been able to figure out why the embedded document isn't removed.
The text was updated successfully, but these errors were encountered: