From c0a372ba87f556769b98a6d06e8c684c3c3156df Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 28 Apr 2009 23:29:29 -0500 Subject: Deprecate template, session, assigns, and layout accessors on response object. Instead access them through the controller instance. This mainly affects functional test assertions. --- actionpack/lib/action_controller/caching/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/caching') diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index b99feddf77..d95a346862 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -121,7 +121,7 @@ module ActionController #:nodoc: end def content_for_layout(controller) - controller.response.layout && controller.response.template.instance_variable_get('@cached_content_for_layout') + controller.template.layout && controller.template.instance_variable_get('@cached_content_for_layout') end end -- cgit v1.2.3 From e59835bd0934a7458b71b13bf65786c8484905bd Mon Sep 17 00:00:00 2001 From: "John F. Douthat" Date: Tue, 21 Apr 2009 13:35:54 -0500 Subject: Fix action-cached exception responses. Methods raising ActiveRecord::RecordNotFound were returning 404 on first request and 200 OK with blank body on subsequent requests. [#2533 state:committed] Signed-off-by: Jeremy Kemper --- actionpack/lib/action_controller/caching/actions.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/caching') diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index d95a346862..2b822b52c8 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -61,7 +61,9 @@ module ActionController #:nodoc: filter_options = { :only => actions, :if => options.delete(:if), :unless => options.delete(:unless) } cache_filter = ActionCacheFilter.new(:layout => options.delete(:layout), :cache_path => options.delete(:cache_path), :store_options => options) - around_filter(cache_filter, filter_options) + around_filter(filter_options) do |controller, action| + cache_filter.filter(controller, action) + end end end @@ -83,6 +85,12 @@ module ActionController #:nodoc: @options = options end + def filter(controller, action) + should_continue = before(controller) + action.call if should_continue + after(controller) + end + def before(controller) cache_path = ActionCachePath.new(controller, path_options_for(controller, @options.slice(:cache_path))) if cache = controller.read_fragment(cache_path.path, @options[:store_options]) -- cgit v1.2.3 From 67cc021d019515c94d4bcc4c3c7060c9a2594c87 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Tue, 19 May 2009 18:05:16 -0700 Subject: Modified caching implementation to work with NewBase --- .../lib/action_controller/caching/actions.rb | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_controller/caching') diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index 2b822b52c8..430db3932f 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -61,8 +61,14 @@ module ActionController #:nodoc: filter_options = { :only => actions, :if => options.delete(:if), :unless => options.delete(:unless) } cache_filter = ActionCacheFilter.new(:layout => options.delete(:layout), :cache_path => options.delete(:cache_path), :store_options => options) - around_filter(filter_options) do |controller, action| - cache_filter.filter(controller, action) + + # TODO: Remove this once new base is swapped in. + if defined?(Http) + around_filter cache_filter, filter_options + else + around_filter(filter_options) do |controller, action| + cache_filter.filter(controller, action) + end end end end @@ -85,14 +91,22 @@ module ActionController #:nodoc: @options = options end + # TODO: Remove once New Base is merged def filter(controller, action) should_continue = before(controller) action.call if should_continue after(controller) end + def around_process_action(controller) + should_continue = before(controller) + yield if should_continue + after(controller) + end + def before(controller) cache_path = ActionCachePath.new(controller, path_options_for(controller, @options.slice(:cache_path))) + if cache = controller.read_fragment(cache_path.path, @options[:store_options]) controller.rendered_action_cache = true set_content_type!(controller, cache_path.extension) @@ -129,7 +143,9 @@ module ActionController #:nodoc: end def content_for_layout(controller) - controller.template.layout && controller.template.instance_variable_get('@cached_content_for_layout') + # TODO: Remove this when new base is merged in + template = controller.respond_to?(:template) ? controller.template : controller._action_view + template.layout && template.instance_variable_get('@cached_content_for_layout') end end -- cgit v1.2.3 From 10085114ce7ec6bc967fa701c49ef218f666efb5 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Mon, 25 May 2009 18:05:58 +0200 Subject: Make Filter#filter work with around filters --- .../lib/action_controller/caching/actions.rb | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'actionpack/lib/action_controller/caching') diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index 430db3932f..3646ff1af9 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -63,7 +63,7 @@ module ActionController #:nodoc: cache_filter = ActionCacheFilter.new(:layout => options.delete(:layout), :cache_path => options.delete(:cache_path), :store_options => options) # TODO: Remove this once new base is swapped in. - if defined?(Http) + if defined?(ActionController::Http) around_filter cache_filter, filter_options else around_filter(filter_options) do |controller, action| @@ -92,16 +92,18 @@ module ActionController #:nodoc: end # TODO: Remove once New Base is merged - def filter(controller, action) - should_continue = before(controller) - action.call if should_continue - after(controller) - end - - def around_process_action(controller) - should_continue = before(controller) - yield if should_continue - after(controller) + if defined?(ActionController::Http) + def around_process_action(controller) + should_continue = before(controller) + yield if should_continue + after(controller) + end + else + def filter(controller, action) + should_continue = before(controller) + action.call if should_continue + after(controller) + end end def before(controller) -- cgit v1.2.3 From f2f58f535520bfa77ab2d0ad1fb598f18349dd2e Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 27 May 2009 17:31:48 -0700 Subject: Fix failing ActionCacheFilter tests due to around filter changes. --- actionpack/lib/action_controller/caching/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/caching') diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index 3646ff1af9..54148b55d8 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -93,7 +93,7 @@ module ActionController #:nodoc: # TODO: Remove once New Base is merged if defined?(ActionController::Http) - def around_process_action(controller) + def filter(controller) should_continue = before(controller) yield if should_continue after(controller) -- cgit v1.2.3