i want to caching my rss feed, this work well,
but i can t delete the generated cache with cache_sweeper:
my feed rss generated by events archive, the public controller:
###### START CODE ########
class RssController < ApplicationController
caches_page :nextevents
def nextevents
@next_events = Event.find(:all)
response.headers[''Content-Type''] =
''application/rss+xml''
respond_to do |format|
format.xml
end
end
end
###### END CODE ########
no my environment.rb:
###### START CODE ########
# .... other code .... #
config.load_paths += %W(#{RAILS_ROOT}/app/sweepers)
# .... other code .... #
###### END CODE ########
i make the dir /sweepers and file inside rss_sweeper.rb:
###### START CODE ########
class RssSweeper < ActionController::Caching::Sweeper
observe Event
def after_create(event)
expire_cache_for(event)
end
def after_update(event)
expire_cache_for(event)
end
def after_destroy(event)
expire_cache_for(event)
end
private
def expire_cache_for(record)
expire_page ( :controller => ''rss'', :action =>
''nextevents'')
end
end
###### END CODE ########
on my administation controller:
###### START CODE ########
class Admin::EventsController < ApplicationController
cache_sweeper :rss_sweeper, :only => [:create, :update, :destroy]
# .... admin crud actions code .... #
end
###### END CODE ########
I suppose the cache_sweeper don'' t work because it run in the sublevel
administration module (Admin).
some suggestion?
--
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
-~----------~----~----~----~------~----~------~--~---