我最近发现多个after_commit
在同一模型中定义的 s 以相反的顺序调用。例如
after_commit method1, :on => :create
after_commit method2, :on => :create
method2
之前被调用 method1
.它总是按 FILO 顺序调用吗?
最佳答案
这种行为在 Rails 5.2.2.1 中仍然存在。
我的解决方案:
after_commit :after_commit_callbacks, :on => :create
def after_commit_callbacks
method1
method2
end
关于ruby-on-rails-3 - 多个 after_commit 回调(Rails)的执行顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30625790/