Observers should support `on:`, e.g. `after_commit on: :create`
paulkoegel opened this issue · 4 comments
paulkoegel commented
rafaelfranca commented
We don't have interest in adding new features to observer. This is why we extracted it from core.
Vorob-Astronaut commented
@rafaelfranca It could be helpful
Right now I have the same problem
heaven commented
Would be great if observers support after_create_commit, after_update_commit, and after_destroy_commit.
salf commented
Next code works well in my application:
def after_commit(post)
if action?(post, [:create, :update])
...
end
end
def action?(object, actions = [])
object.send(:transaction_include_any_action?, actions)
end
rails 4.2.8