开发者

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'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜