rails/rails — pull request #12026 by hornairs (2013-08-26 18:08:21+00:00)
Title: Make AR::Base#touch fire the after_commit and after_rollback callbacks

I expected

```ruby
class Product < ActiveRecord::Base
after_commit :expire_cache

def expire_cache
puts "cache expired"
end

product.touch
```

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_commit` callbacks, woo!

We relied on `after_commit` callbacks 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 add `after_touch` callbacks 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!