Skip to content


caches_action :if method still called when filter chain is halted #1918

rywall opened this Issue · 3 comments

4 participants

class ProjectsController < ApplicationController
  before_filter :cancel_action, :only => [:index]

  caches_action :index, :if => :explode

  def index
    render :text => "Projects Index"

  def new
    render :text => "Project New"

  def explode "Calling caches_action if"
    raise "Explosion since we weren't expecting to run this method"

  def cancel_action "Trying to cancel"
    redirect_to :action => :new

A simple (contrived) example. If you try to access the ProjectsController#index method it halts the filter chain by redirecting to the new action, BUT Rails still runs the if method for caches_action even though the response was generated by the before_filter so there is no point trying to cache it.

Confirmed in 3.0.9 and master.


caches_action is a simple around_filter.

Therefore it means all around_filters get executed even though a previous before_filter has halted the chain.


@rywall Is this still an issue? If not, please close it. Thanks.

Ruby on Rails member

Closing due to no activity. If this is still an issue, please comment and I'll reopen. Thanks!

@tenderlove tenderlove closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.