#76 ✓hold
Dylan Stamat

Core changes in fragment_cache.rb

Reported by Dylan Stamat | August 3rd, 2007 @ 08:35 PM

In the before method, the way the action_cache_path is generated has been changed.

Used to be:

action_cache_path = ActionController::Caching::Actions::ActionCachePath.new(controller)

Is now:

action_cache_path = ActionCachePath.new(controller, path_options_for(controller, @options))

There is an additional private method path_options_for that does some nice magic.

Was running into problems with incorrect cache paths being generated for nested resources... ie: /blogs and /groups/xxxx/blogs were both keyed as /blogs.

Didn't have time to dig into the specifics, and don't have time to write a patch... but just thought I'd throw it out there that this method has changed quite a bit ;) I ran into this bug, patched locally (very hacky like), then realized it had changed in core... go figure.

Will catch up on this ticket when I have some time... assuming it is still here. Word up !

Comments and changes to this ticket

  • Chris Wanstrath

    Chris Wanstrath August 3rd, 2007 @ 08:35 PM

    • State changed from “new” to “hold”

    Cool, please re-open when you have more time or a fix. Thanks for letting us know about this.

  • Will Bryant

    Will Bryant November 25th, 2007 @ 04:10 PM

    How about:

    --- old-connect-2/vendor/plugins/cache_fu/lib/acts_as_cached/fragment_cache.rb  2007-11-26 13:08:39.000000000 +1300
    +++ new-connect/vendor/plugins/cache_fu/lib/acts_as_cached/fragment_cache.rb    2007-11-26 13:08:41.000000000 +1300
    @@ -58,9 +58,8 @@
               if @options
                 action_cache_path = ActionController::Caching::Actions::ActionCachePath.new(controller, path_options_for(controller, @options))
               else
    -            action_cache_path = ActionController::Caching::Actions::ActionCachePath.new(controller)
    +            action_cache_path = ActionController::Caching::Actions::ActionCachePath.new(controller, controller.params)
               end
    -          
               # should probably be like ActiveRecord::Validations.evaluate_condition.  color me lazy.
               if conditional = @actions[controller.action_name.intern][:if]
                 conditional = conditional.respond_to?(:call) ? conditional.call(controller) : controller.send(conditional)
    @@ -87,7 +86,7 @@
             def after(controller)
               return if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache
               # 1.2.x compatibility
    -          path = controller.respond_to?(:action_cache_path) ? controller.action_cache_path.path : ActionController::Caching::Actions::ActionCachePath.path_for(controller)
    +          path = controller.respond_to?(:action_cache_path) ? controller.action_cache_path.path : ActionController::Caching::Actions::ActionCachePath.path_for(controller, controller.params)
               controller.write_fragment(path, controller.response.body, action_ttl(controller))
             end
    
  • Will Bryant

    Will Bryant November 25th, 2007 @ 04:15 PM

    Hmm, didn't mean to remove that blank line in the middle there, leave that out of the patch :)

  • Dylan Stamat

    Dylan Stamat November 25th, 2007 @ 04:55 PM

    Awesome, thanks Will :) Chris, could you check it out and possibly apply or reopen ? Thanks !

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

Shared Ticket Bins

Tags

Pages