I have read the documentation at http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html, but don't understand when the around_*
callbacks are triggered in relation to before_*
and after_*
.
Any help much appreciated.
Thanks.
I have read the documentation at http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html, but don't understand when the around_*
callbacks are triggered in relation to before_*
and after_*
.
Any help much appreciated.
Thanks.
around_*
callbacks are invoked before the action, then when you want to invoke the action itself, youyield
to it, then continue execution. That's why it's calledaround
The order goes like this:
before
,around
,after
.So, a typical
around_save
would look like this:The around_* callback is called around the action and inside the before_* and after_* actions. For example: