-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
class Parent include Mongoid::Document embeds_one :child, :cascade_callbacks => true end
class Child include Mongoid::Document before_create :always_fail def always_fail puts "failing..." errors.add :base, "boo hoo" false end end
1.9.3p194 :041 > p = Parent.new => #<Parent _id: 4ffb17ce73f05750ce000005, _type: nil> 1.9.3p194 :042 > p.build_child => #<Child _id: 4ffb17de73f05750ce000006, _type: nil> 1.9.3p194 :043 > p.save failing... => true 1.9.3p194 :044 > p.child.errors => #<ActiveModel::Errors:0x00000005ae7d10 @base=#<Child _id: 4ffb17de73f05750ce000006, _type: nil>, @messages={:base=>["boo hoo"]}> 1.9.3p194 :045 > p.child.persisted? => true 1.9.3p194 :046 > p.child.changed? => false