Rails 3: Expiring cached public/index.html page
I have the following line on my routes.rb file.
root :to => "portfolio#index"
I cached the index page as follow:
class PortfolioController < ApplicationController
caches_page :index
def index
开发者_JAVA百科 @portfolio = Portfolio.where("featured = ? AND enabled = ?", false, true)
end
end
And the PortfolioSweeper.rb
class PortfolioSweeper < ActionController::Caching::Sweeper
observe Portfolio
def after_save(portfolio)
expire_cache(portfolio)
end
def after_destroy(portfolio)
expire_cache(portfolio)
end
private
def expire_cache(portfolio)
expire_page :controller => 'portfolio', :action => 'index'
end
end
What is happening is that the expire_page
only removes the /public/portfolio.html page but NOT /public/index.html page. Can you guys think of a way to remove both files?
Try just passing it the path, like:
expire_page '/index.html'
精彩评论