diff options
-rw-r--r-- | actionpack/lib/action_controller/components.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_controller/flash.rb | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/components.rb b/actionpack/lib/action_controller/components.rb index 312595c21f..62f6ee518d 100644 --- a/actionpack/lib/action_controller/components.rb +++ b/actionpack/lib/action_controller/components.rb @@ -50,9 +50,13 @@ module ActionController #:nodoc: private def component_response(options, reuse_response = true) - c = component_class(options) - c.after_filter {|c| flash.keep } - c.process(request_for_component(options), reuse_response ? @response : response_for_component) + begin + ActionController::Flash::FlashHash.avoid_sweep = true + Thread.current[:p] = component_class(options).process(request_for_component(options), reuse_response ? @response : response_for_component) + ensure + ActionController::Flash::FlashHash.avoid_sweep = false + end + Thread.current[:p] end def component_class(options) diff --git a/actionpack/lib/action_controller/flash.rb b/actionpack/lib/action_controller/flash.rb index 674f73f1a4..df2863e0b6 100644 --- a/actionpack/lib/action_controller/flash.rb +++ b/actionpack/lib/action_controller/flash.rb @@ -43,6 +43,9 @@ module ActionController #:nodoc: end class FlashHash < Hash + @@avoid_sweep = false + cattr_accessor :avoid_sweep + def initialize #:nodoc: super @used = {} @@ -99,6 +102,7 @@ module ActionController #:nodoc: # # This method is called automatically by filters, so you generally don't need to care about it. def sweep #:nodoc: + return if @@avoid_sweep keys.each do |k| unless @used[k] use(k) |