when is around_create callback code executed, in what situations we should use it?
Had this question, too, and have now found the answer: around_create
allows you to basically do both a before_create
and an after_create
in one method. You have to use yield
to execute the save in between.
class MyModel < ActiveRecord::Base
around_create :my_callback_method
private
def my_call_back_method
# do some "before_create" stuff here
yield # this makes the save happen
# do some "after_create" stuff here
end
end