Coming in late, but this might be helpful... I've used this from ./ script/runner... not quite rake, but...
... require 'lib/console_app' ... ActionController::Base.expire_page(app.user_profile_path(:id => user.username)) ... (where 'user_profile' is a named route) On Feb 28, 2009, at 7:31 PM, Levy Carneiro Jr. wrote: > Thanks, Vincent. > > I just wanted to know if there was something better. I guess I'll > resort to > the File.delete and friends as you mentioned :) > > Regards, > Levy > > > On Sun, Feb 22, 2009 at 2:09 PM, Wincent Colaiuta <[email protected]> > wrote: > >> >> On Feb 11, 11:14 am, "Levy Carneiro Jr." <[email protected]> >> wrote: >> >>> I tried this also: >>> >>> class ArchivesObserver < ActionController::Caching::Sweeper >>> (...) >>> >>> In this case, there's no error, and it does nothing at all. The >>> public/archives.html just stays there. >>> >>> I'm trying my best to avoid hacking it, using a simple >>> File.delete :) >>> Like the code below: >>> >>> # File rails/actionpack/lib/action_controller/caching/pages.rb, >>> line >> 65 >>> 65: def expire_page(path) >>> 66: return unless perform_caching >>> 67: >>> 68: benchmark "Expired page: #{page_cache_file(path)}" do >>> 69: File.delete(page_cache_path(path)) if >>> File.exist?(page_cache_path(path)) >>> 70: end >>> 71: end >>> >>> Is there a way to expire pages without having to hack it? >> >> I ran into a similar issue a few days ago. If I remember correctly, >> if >> you look at what Rails is doing under the covers, you'll see that >> ActionController::Caching::Sweeper subclasses will only work when >> called from inside a controller. Basically the "expire_page" message >> ends up getting intercepted by "method_missing", which tries to >> forward it on to a controller stored in the @controller instance >> variable. So if you invoke your Sweeper subclass from somewhere else >> (like a Rake task), that @controller variable will be nil and nothing >> will happen. >> >> My workaround was just to fall back to File.delete and friends. Ugly, >> but it works. >> >> Cheers, >> Wincent >>> >> > > > --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

