Steven Cummings
2010-Sep-08 13:18 UTC
Re: Call expire_fragment from outside sweepers or controllers
xponrails wrote:> Hi all. > > I need to expire cached fragments from outside sweepers or > controllers: I have a rake task that calls a method inside a module in > the /lib directory. This task will be called at a scheduled time by a > crontab job. > > After method execution I would like to expire some cached fragments. > > I''ve just tried to import ActionController::Caching and > ActionController::Caching::Fragment, but without success. > > Do you have any suggestions?I had exactly the same problem and managed to come up with a solution (albeit with a couple of limitations). My solution involves keeping all the code in the Sweeper and calling it via a class method, so it should work anywhere. See my blog entry for an explanation and the code. http://stevencummings.name/2010/09/07/expire_fragment-with-rake-and-as-a-model-only-observer -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.