-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
When validates_presence_of embeds_many documents fails on update_atrtibutes a mongo "pullAll" command is executed and embeds_many is deleted. Example:
class Ho include Mongoid::Document embeds_many :heys field :name, type: String validates_presence_of :heys end
class Hey include Mongoid::Document embedded_in :ho field :name, type: String end
ho = Ho.new ho.heys = [Hey.new] ho.save! ho.heys >> [#<Hey _id: 5295387669a951f9a4000004, name: nil>] ho.update_attributes!({"heys"=>nil}) >> MOPED: 127.0.0.1:27017 UPDATE database=database_name collection=hos selector={"_id"=>"529537f669a951f9a4000002"} update={"$pullAll"=>{"heys"=>[{"_id"=>"5295387669a951f9a4000004"}]}} flags=[] (0.2277ms) >> Mongoid::Errors::Validations: Problem: Validation of Ho failed. Summary: The following errors were found: Heys translation missing: pt-BR.mongoid.errors.models.ho.attributes.heys.blank Resolution: ho.reload ho.heys >> []