-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
When returning false in an around_create callback, this will cancel the document creation as expected. However, after_create callbacks will still be triggered. This behavior does not occur with before_create. Mongoid 2.4.12 and Mongoid 3.0.1 have the same results. Here is the example code:
class A include Mongoid::Document before_create { false } after_create { p 'not here' } end class B include Mongoid::Document around_create { false } after_create { p 'but here?' } end class Observer < Mongoid::Observer observe :a, :b def after_create(o); p "#{o.class} - and here?"; end end Mongoid.observers = Observer Mongoid.instantiate_observers a = A.new; p a.save b = B.new; p b.save
I would expect the output to be:
false false
Instead, the output is:
false "but here?" "B - and here?" false
Is this a bug or expected behavior?