Ruby on Rails
Monday, May 20, 2019
I have a product
table and I try to run after_commit and after_rollback on create.
controller:
product = Product.new form_params if product.save # code else # code end
model:
after_commit(on: :create) { # code } after_rollback(on: :create) { # code }
after_commit works well but after_rollback wont work with on: :create
param. When I remove the on: :create
param, it triggers too but I need after_rollback to trigger just on create.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c0ad4f7b-d303-4fb8-8dc2-f72ea3517573%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment