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_action with conditional

#166

A couple of changes were made to ActionController::Caching::Actions:

  • Added conditional option (:if) to caches_action method (just like in caches_page)
  • Added :layout flag to caches_action method. If you specify :layout => false, the layout will not be cached, only the action content. This is useful since most application has user info in the layout. If the :layout is not set or set to true, we have the default behavior.
  • Changes were documented
  • Tests were added
  • Test bug fix: added sleep(0.01) to assure that Time.now will be different.

The patch is attached.

Reported by José Valim · May 11th, 2008 @ 03:30 PM

State: resolved
Milestone: none
Assigned to: josh josh
Importance: none

Activity

  1. Repository
    Repository
    • State changed from new to resolved

    (from [9a137506a1267ec5938fcec4d2ff135f15037459]) Added not to sanitize helper docs that it doesn't guarantee well-formed markup.

    Signed-off-by: Michael Koziarski

    [#166 state:resolved]

    http://github.com/rails/rails/co...

    May 11th, 2008 @ 11:22 PM

  2. Michael Koziarski
    Michael Koziarski
    • State changed from resolved to new

    whoops

    May 11th, 2008 @ 11:28 PM

  3. Michael Koziarski
    Michael Koziarski

    Could we have the patch without the :layout option? I'm not necessarily sold on that one prior to 2.1, but :if looks good.

    May 11th, 2008 @ 11:29 PM

  4. José Valim
    José Valim
    • Title changed from [PATCH] caches_action extension (with :if and :layout keys) to [PATCH] caches_action with conditional

    :layout option removed! =)

    Should I do another patch just with the :layout option?

    And I don not know if would be important to document, but all parameters give to caches_action (except for :caches_path) are passed to the around_filter. This means that we can use the conditional (:if) and, also, use :only and :except to specify the actions we want to cache.

    The same happens with caches_page.

    May 12th, 2008 @ 12:26 AM

  5. Pratik
    Pratik
    • Title changed from [PATCH] caches_action with conditional to caches_action with conditional

    May 13th, 2008 @ 12:06 PM

  6. josh
    josh
    • Assigned user set to josh

    Looks good, but its making my AR integration tests fail for some reason. Maybe it has something todo w/ the tests you changed. Anyone else having this problem?

    Updated

    Its not related to the tests. The integration tests will fail only if the patch is applied to actions.

    May 13th, 2008 @ 10:22 PM

  7. Pratik
    Pratik

    Works fine for me.

    May 13th, 2008 @ 10:21 PM

  8. José Valim
    José Valim

    It's also working fine for me.

    I didn't get where is the problem yet (if there is any).

    May 14th, 2008 @ 03:13 AM

  9. Pratik
    Pratik
    • State changed from new to incomplete

    Can you please use mocking instead of sleep(0.01) ?

    Thanks.

    May 14th, 2008 @ 12:15 PM

  10. José Valim
  11. José Valim
    José Valim

    Here we go!

    As Pratik asked, I'm using a MockTime instead of sleep(0.01).

    All tests pass!

    May 14th, 2008 @ 06:26 PM

  12. josh
    josh
    • State changed from incomplete to open

    Hurray! Tests are passing. We'll take that patch ;)

    May 14th, 2008 @ 06:31 PM

  13. Repository
    Repository
    • State changed from open to resolved

    (from [7708650f73ddb4db300ea2059c60c1d907a4384e]) Added conditional support to caches_action [José Valim] [#166 state:resolved]

    http://github.com/rails/rails/co...

    May 14th, 2008 @ 06:34 PM