-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"after_commit on: :create" callback is called when destroying model instance with activerecord 6.0.0.rc1 #473
Comments
@eitoball yo can use object.deleted? on if block like |
Ran into this same thing, @bishosilwal 's suggestion worked as a stop gap. Tried to poke around a little bit but I don't know that I found anything useful. Rails does replace the use of |
I am hitting this now in the process of upgrading rails 5.2 to 6.0 as well. I suppose I will use the |
@anirbanmu thanks for the pointer. I would advise against using the lambda. I ran into a strange regression with callback order when performing methods against ActiveRecord models in I didn't have a chance to look deeper but would advise to use a |
@arlando that is very interesting that a See this section https://api.rubyonrails.org/classes/ActiveSupport/Callbacks/ClassMethods.html#method-i-set_callback It seems to say you can use proc or lambda: |
@anirbanmu thanks for the pointer if I have some time I'll set up a gist showing the issue. |
Hitting the same bug on Rails 6.1.6.1, the |
When destroying model instance in activerecord 6.0.0.rc1, it seems that
after_commit on: :create
callback is called.A sample code that can reproduce this isuue is attached in "Code" section. When running this code with activerecord 6.0.0.rc1, it outputs ">>>>> after_commit_on_create" line twice. With activerecord 5.2.3, it outputs once.
Is this issue in paranoia? Or am I setting callbacks in wrong way?
TIA
Code
Output
Gemfile
Gemfile.lock
The text was updated successfully, but these errors were encountered: