Permalink
Browse files

Take a different approach to keeping flash around when using components.

One that, you know, doesn't involve consuming every byte of free memory
on the system.

Closes #2589.

References #2291.



git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2722 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent f57ba4c commit 3a2943c54de7e288ac2443556257df7b2d69ac68 Scott Barron committed Oct 25, 2005
Showing with 11 additions and 3 deletions.
  1. +7 −3 actionpack/lib/action_controller/components.rb
  2. +4 −0 actionpack/lib/action_controller/flash.rb
@@ -50,9 +50,13 @@ def render_component_as_string(options) #:doc:
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)
@@ -43,6 +43,9 @@ def []=(k, v)
end
class FlashHash < Hash
+ @@avoid_sweep = false
+ cattr_accessor :avoid_sweep
+
def initialize #:nodoc:
super
@used = {}
@@ -99,6 +102,7 @@ def discard(k=nil)
#
# 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)

0 comments on commit 3a2943c

Please sign in to comment.