caching - How to get true after_destroy in Rails? -
i have after_destroy
model callback regenerates cache after model instance has been destroyed. calling open("http://domain.com/page-to-cache")
many pages need re-cached.
the problem model instance apparently isn't destroyed yet @ time, because open url requests still register presence, , regenerated cache looks pre-destroy cache. how can run calls after model instance has been destroyed?
you may able use after_commit
callback after entire transaction has gone through database. different depending on version of rails you're using (2.3.x versus 3.x.x), following:
# model_observer.rb class modelobserver < activerecord::observer def after_commit(instance) do_something if instance.destroyed? end end
you can read documentation rails 3 after_commit
callback here. if version of rails doesn't have after_commit
hook, can try using this gem provide functionality.
Comments
Post a Comment