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

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -