Page caching with custom routes


#1

hi ,

I’m having problems with expire_page with custom routes
i’ll show some code

blog_controller

def clear_cache_rss_artikels
expire_page url_for(:controller => “xml”,:action => “rss_artikels”)
end

this is called when a new article is posted or edited or destroyed

xml_controller

class XmlController < ApplicationController
caches_page :rss_artikels

def rss_artikels
@articles = Article.find(:all)
end

end

routes.rb

map.rss “rss/blog/artikels”,:controller => “xml”,:action =>
“rss_artikels”

when the rss feed is called , rails make a file in the public directory
rss/blog/artikels.html

but i can’t expire the page ,i think something is wrong with
clear_cache_rss_artikels , the routes aren’t called at the moment when
expired_page is called or could somebody help me?

greetz

Klaas


#2

Hi Klaas

I don’t think you need to call the url_for() method. Your expire
method should look like:

def clear_cache_rss_artikels
expire_page(:controller => “xml”,:action => “rss_artikels”)
end

Hope this helps,
Simon