Hi,
I''ve started to implement page caches but I''ve hit a brick
wall getting
a sweeper to clear the cache when needed. It seems that any models that
I tell it to observe aren''t being observed properly. If I add the
sweeper to a controller the initialize method runs, but no matter what I
do the after_save/after_update callbacks aren''t running. Also if I try
to call "expire_page", I get a method missing error. It seems like the
class isn''t actually extending the Sweeper at all, is there something
I''m missing??
Here''s the sweeper code:
class PublishSweeper < ActionController::Caching::Sweeper
observe Program
def initialize
puts "sweeper initialised"
end
def after_save(record)
puts "The sweeper knows that node: #{record.inspect} has been
saved!"
end
def after_update(record)
puts "The sweeper knows that node: #{record.inspect} has been
updated!"
end
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
-~----------~----~----~----~------~----~------~--~---
Daniel Greig wrote:> Hi, > > I''ve started to implement page caches but I''ve hit a brick wall getting > a sweeper to clear the cache when needed. It seems that any models that > I tell it to observe aren''t being observed properly. If I add the > sweeper to a controller the initialize method runs, but no matter what I > do the after_save/after_update callbacks aren''t running. Also if I try > to call "expire_page", I get a method missing error. It seems like the > class isn''t actually extending the Sweeper at all, is there something > I''m missing??Did you tell your controller to use the sweeper? class PublishController < ApplicationController cache_sweeper :publish_sweeper 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 -~----------~----~----~----~------~----~------~--~---
Yep, I''ve got the sweeper being used in a couple of controllers - all of them initialize it, but no model changes are being observed (or at least the sweeper isn''t being alerted to the model changes) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Did you tell config/environment.rb where and how to load the sweepers? That one bite me a while back. If you didn''t add it to config.load_paths in the Rails::Initializer block there. Hope that helps. RSL On 2/14/07, dang <dgreig-vQs5aMGR+7nQT0dZR+AlfA@public.gmane.org> wrote:> > > Yep, I''ve got the sweeper being used in a couple of controllers - all > of them initialize it, but no model changes are being observed (or at > least the sweeper isn''t being alerted to the model changes) > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Russell Norris wrote:> Did you tell config/environment.rb where and how to load the sweepers? > That > one bite me a while back. If you didn''t add it to config.load_paths in > the > Rails::Initializer block there. Hope that helps. > > RSLThanks for the responses, I think I''m going to blame webrick - even when I configrated (my new favourite made up word) caching in dev mode, webrick didn''t play nice. Switching to mongrel seems to make it happy. -- 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 -~----------~----~----~----~------~----~------~--~---