class User < ActiveRecord::Base
after_commit :cache_user, :on => :create
puts "Caching user"
self.cached = true
triggers same cache_user method again when save gets called from cache_user method. I believe, calling save from after_commit(:on => :create) hook should ideally only trigger if there is a after_commit(:on => :update) callback is registered.
The reason this is happening is - recorded transaction states get cleared only after after_commit callback returns, whereas I believe this bug can be fixed by clearing transaction state before entering after_commit callback.
after_commit(:on => :create)
after_commit(:on => :update)
I have attached a pull request, #6226 . @tenderlove can you please have a look?
Closed by #6226
Does anyone know what version of rails the fix for this made it into?