Make AR::Base#touch fire the after_commit and after_rollback callbacks#12031
Closed
airhorns wants to merge 1 commit into
Closed
Make AR::Base#touch fire the after_commit and after_rollback callbacks#12031airhorns wants to merge 1 commit into
airhorns wants to merge 1 commit into
Conversation
Member
|
👍 |
Contributor
There was a problem hiding this comment.
Need one line before on_after_commit method!
Contributor
|
Please add Changelog |
Contributor
Author
|
@pftg updated, thanks for the feedback |
|
👍 |
Contributor
Author
|
Bump? |
|
We've been running this in production via a monkey patch for 4 months. Works as intended. |
Contributor
Author
|
Us at Shopify too |
Member
|
Hey folks, sorry I missed this one, already marked it here to take a look as soon as I find some time here. Thanks! |
Member
|
I think we wanna close this PR, and open another one against master... =( , than we backport if needed. |
carlosantoniodasilva
added a commit
that referenced
this pull request
Jan 16, 2014
Make AR::Base#touch fire the after_commit and after_rollback callbacks. Closes #12031. Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/integration_test.rb
huoxito
added a commit
to huoxito/rails
that referenced
this pull request
Mar 14, 2014
As of rails#12031 after_commit and after_rollback are also executed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I expected
to output "cache expired", but it doesn't, and it used to in Rails 3.0. This PR brings back that functionality by making touches call
after_commitcallbacks, woo!We relied on
after_commitcallbacks being fired by touches to do things like expire caches, send documents to our search cluster, bump versions in Redis, etc. When we upgraded to 3.2, we found this problem and had to go and addafter_touchcallbacks to all those places to get touches to cause the same changes in the system. We make pretty heavy use of touches to bump timestamps up the association chain and whatnot, so they are a principle instigator of attribute change in the system. I think having to add both callbacks to really get a callback fired when stuff changes is sucky because it means client code has to deal with de-duplication if both callbacks fire, client code has to be aware of the semantic differences of when they fire, and before this change there is no way to get called back to when a record's timestamp bump has definitely been committed to the database.Thanks for any feedback you can give me!
@carlosantoniodasilva this is a follow up to #12026 on top of
4-0-stable, is this what you need?