问题描述
我已阅读,但是不理解何时在之前触发
和 around _ *
回调之前_ *
任何帮助非常感谢。
感谢。
/ strong>动作,那么当你想调用动作本身时,你
yield
就可以了,然后继续执行。这就是为什么它叫 周围
订单如下: 因此,典型的 I have read the documentation at http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html, but don't understand when the Any help much appreciated. Thanks. The order goes like this: So, a typical 这篇关于Rails:around_ * callbacks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!之前
,,
, b $ b
around_save
看起来像这样:
def around_save
#do something ...
yield #saves
#do something else ...
end
around_*
callbacks are triggered in relation to before_*
and after_*
.around_*
callbacks are invoked before the action, then when you want to invoke the action itself, you yield
to it, then continue execution. That's why it's called around
before
, around
, after
.around_save
would look like this:def around_save
#do something...
yield #saves
#do something else...
end