Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#1113

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.

e.g.


class PagesController < ApplicationController
  #configure the pages we cache
    caches_page :show, :if => Proc.new {|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 => Proc.new {|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.

Reported by scottru (at gmail) · September 25th, 2008 @ 06:41 PM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. claytonlz
    claytonlz
    • 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.

    September 30th, 2008 @ 08:59 AM

  2. Pratik
    Pratik
    • State changed from new to incomplete

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

    Thanks

    January 5th, 2009 @ 05:48 PM

  3. Ryan Bigg
    Ryan Bigg
    • State changed from incomplete to invalid

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

    April 11th, 2010 @ 02:26 AM