Rodrigo Soares
Rodrigo Soares

Reputation: 346

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
    @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?

Upvotes: 0

Views: 1092

Answers (1)

Callmeed
Callmeed

Reputation: 4992

Try just passing it the path, like:

expire_page '/index.html'

Upvotes: 3

Related Questions