I''ve enabled page caching on a site I''m currently
constructing. The
sweeper is called upon any changes made to the model, as expected.
The sweeper code is as follows:
class PersonSweeper < ActionController::Caching::Sweeper
observe Person
def after_update(person)
expire_staff_page
end
def after_destroy(person)
expire_staff_page
end
def expire_staff_page
$stderr.puts "@@@@@ Expiring staff page"
expire_page( :controller => ''welcome'', :action =>
''staff'' )
$stderr.puts "@@@@@ Staff Page Expired"
end
end
In my administrative controller, I have
class Admin::PeopleController < Admin::AdminBaseController
cache_sweeper :person_sweeper
and finally, in the public controller, I have
class WelcomeController < ApplicationController
caches_page :staff
When I hit the public ''staff'' page, the cache file is created.
When
changes are made to the underlying data model, the sweeper method is
invoked, and I see
@@@@@ Expiring staff page
@@@@@ Staff Page Expired
in the server logs. However, the generated file in public/welcome/
staff.html is not removed.
What am I doing wrong?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Solved it. Instead of expire_page( :controller => ''welcome'', :action => ''staff'' ) I should have used expire_page( :controller => ''/welcome'', :action => ''staff'' ) I guess the issue was that I''m trying to expire content generated in a controller different from the one that initially created the cached page. Instead of expiring ./public/welcome/staff.html, ./public/admin/ welcome/staff.html was being expired. It didn''t exist, so of course nothing happened. --~--~---------~--~----~------------~-------~--~----~ 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 ran into the same administration / sweeper problem. Although I''ve got it working, I''m still unclear about how it all works. My revelation was that the admin controller needed the cache_sweeper :person_sweeper , no the ''front'' controller. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---