开发者

Rails 3: Expiring cached public/index.html page

开发者 https://www.devze.com 2023-02-05 11:08 出处:网络
I have the following line on my routes.rb file. root :to => \"portfolio#index\" I cached the index page as follow:

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

精彩评论

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

关注公众号