-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
If I have a document with many embedded documents:
class Pack include Mongoid::Document embeds_many :items validates_presence_of :items accepts_nested_attributes_for :items, allow_destroy: true end
I can destroy all the items, with the standard rails _destroy option used with update_attributes:
@pack.update_attributes params[:pack]
At this point, the pack will have no items. If then I make a second edit to the pack, changing some other field, then the validator will activate and prevent the save.
Presumably this is because the items are individually destroyed, rather than perhaps being marked as to_destroy, and then actually destroyed with the parent document is saved.
- duplicates
-
MONGOID-3808 Mongoid 3.1.6 presence: true on embeds_many relation
- Closed