This project is archived and is in readonly mode.

#1113 ✓invalid
scottru (at gmail)

caches_page :if is ignored (but caches_action :if works)

Reported by scottru (at gmail) | September 25th, 2008 @ 06:41 PM | in 2.x

I've narrowed this down to the smallest case I can:

In a controller with no before_filters specified in either that controller or its parents, caches_page :if still ignores the :if clause.


class PagesController < ApplicationController
  #configure the pages we cache
    caches_page :show, :if => {|c| ["home", "test-page"].index(c.request.path_parameters["id"])}

never evaluates the :if - it caches every time. In fact, if you replace the command with nonsense, like

class PagesController < ApplicationController
    caches_page :show, :if => {|c| dsaasasdadsasd}

all pages are still cached.

I've commented out all before_filters in this controller and in ApplicationController, no impact. There are some before_filters in libraries but it's not obvious why those would matter.

Replacing caches_page with caches_action works as expected.

Let me know if I can help debug.

Comments and changes to this ticket

  • claytonlz

    claytonlz September 30th, 2008 @ 08:59 AM

    • Tag changed from bug, caching to bug, caches_page, caching

    I am trying to implement a patch for this but I'm having a tough time getting the tests to pass correctly. I think the page caching test controller in caching_test.rb is poorly implemented.

    I also tried looking at the way the action caching works, but it's implementation is different. I also followed the arguments from caches_page up the stack and from append_after_filter to update_filter_chain the "if" conditional never seemed to be evaluated.

  • Pratik

    Pratik January 5th, 2009 @ 05:48 PM

    • State changed from “new” to “incomplete”

    Could you please provide a failing test case in Action Pack test suite ?


  • Ryan Bigg

    Ryan Bigg April 11th, 2010 @ 02:26 AM

    • State changed from “incomplete” to “invalid”

    This is covered in 14a40804. If this is broken, this test will fail.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>