问题
I recently found that multiple after_commit
s defined in the same model get called in reverse order. For example
after_commit method1, :on => :create
after_commit method2, :on => :create
method2
gets called before method1
.
Is it always called in FILO order?
回答1:
This behaviour is still present in Rails 5.2.2.1.
My solution:
after_commit :after_commit_callbacks, :on => :create
def after_commit_callbacks
method1
method2
end
来源:https://stackoverflow.com/questions/30625790/execution-order-of-multiple-after-commit-callbacks-rails