Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 2722

Show
Ignore:
Timestamp:
10/25/05 00:38:51 (3 years ago)
Author:
htonl
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/components.rb

    r2604 r2722  
    5151    private 
    5252      def component_response(options, reuse_response = true) 
    53         c = component_class(options) 
    54         c.after_filter {|c| flash.keep } 
    55         c.process(request_for_component(options), reuse_response ? @response : response_for_component) 
     53        begin 
     54          ActionController::Flash::FlashHash.avoid_sweep = true 
     55          Thread.current[:p] = component_class(options).process(request_for_component(options), reuse_response ? @response : response_for_component) 
     56        ensure 
     57          ActionController::Flash::FlashHash.avoid_sweep = false 
     58        end 
     59        Thread.current[:p] 
    5660      end 
    5761     
  • trunk/actionpack/lib/action_controller/flash.rb

    r2649 r2722  
    4444     
    4545    class FlashHash < Hash 
     46      @@avoid_sweep = false 
     47      cattr_accessor :avoid_sweep 
     48       
    4649      def initialize #:nodoc: 
    4750        super 
     
    100103      # This method is called automatically by filters, so you generally don't need to care about it. 
    101104      def sweep #:nodoc: 
     105        return if @@avoid_sweep 
    102106        keys.each do |k|  
    103107          unless @used[k]