Hi All, I am trying to expire a fragment cache in rake. I know that the best practice to expire the cache is in the Sweepers. But as I have to expire the cache at the end of the month I was thinking on the lines of doing it in a rake task. I had tried this but it showed me an error while running the task expire_fragment(:controller => :login, :action => :index, :something=> "1") Well it gives me a "No method Error" Wanted to know what is the best practice to clear the cache on a cron job? Should a sweeper action be called or a rake task is prescribed? If any one has done this would highly appreciate if he/she could provide the code for calling a sweeper action from a cron or can someone point out what I am missing in the rake file. Do I have to create an object and then call the method if so then an object of what class? Please pardon me for being such a newbie. Any help would be highly appreciated. Cheers, Jazzy -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Any body knows how to get this done? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hate to bring back an old topic but I just came across this in my frantic search to find a solution to much the same problem. So here it goes: In you rake task call: ApplicationController.expire_page(...) -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Silviu lucian Vacaroiu wrote:> Hate to bring back an old topic but I just came across this in my > frantic search to find a solution to much the same problem. So here it > goes: > > In you rake task call: ApplicationController.expire_page(...)of course, make sure your environment gets setup first: task :expire_cache => :environment do ApplicationController.expire_page(:controller => "welcome") end -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
no, sorry, scratch that I was trying it in the console and though it was working there I realize now it''s not the same thing. In the end I got away with using something like: task :expire_cache => :environment do ActionController::Base::expire_page(''/'') end In my case, I wanted to delete ''index.html'' (root page-cache) -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I struggled with this problem the other night and managed to come up with solution that allowed me to to use the code from my Sweeper instead of duplicating it in rake. I wrote a blog entry explaining what I did along with code samples. 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.
jazzy jazzy wrote:> Hi All, > I am trying to expire a fragment cache in rake. I know that the best > practice to expire the cache is in the Sweepers. But as I have to expire > the cache at the end of the month I was thinking on the lines of doing > it in a rake task. > I had tried this but it showed me an error while running the task >You could look into Rails.cache.delete(path_and_fragment_name) -- 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.