Forum: Ruby on Rails cache_sweeper problem deleting cache

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aldo I. (Guest)
on 2008-12-11 16:01
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?
This topic is locked and can not be replied to.