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

Changeset 2363

Show
Ignore:
Timestamp:
09/27/05 11:02:11 (3 years ago)
Author:
htonl
Message:

Keep flash after component is rendered. Closes #2291.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r2345 r2363  
    11*SVN* 
     2 
     3* Keep flash after components are rendered. #2291 [Rick Olson, Scott] 
    24 
    35* Shorten IE file upload path to filename only to match other browsers.  #1507 [court3nay@gmail.com] 
  • trunk/actionpack/lib/action_controller/components.rb

    r887 r2363  
    4444    private 
    4545      def component_response(options, reuse_response = true) 
    46         component_class(options).process(request_for_component(options), reuse_response ? @response : response_for_component) 
     46        c = component_class(options) 
     47        c.after_filter {|c| flash.keep } 
     48        c.process(request_for_component(options), reuse_response ? @response : response_for_component) 
    4749      end 
    4850     
  • trunk/actionpack/test/controller/components_test.rb

    r757 r2363  
    2626  end 
    2727 
     28  def set_flash 
     29    render_component(:controller => 'callee', :action => 'set_flash') 
     30  end 
     31 
     32  def use_flash 
     33    render_component(:controller => 'callee', :action => 'use_flash') 
     34  end 
     35 
    2836  def rescue_action(e) raise end 
    2937end 
     
    3644  def blowing_up 
    3745    render_text "It's game over, man, just game over, man!", "500 Internal Server Error" 
     46  end 
     47   
     48  def set_flash 
     49    flash[:notice] = 'My stoney baby' 
     50    render :text => 'flash is set' 
     51  end 
     52   
     53  def use_flash 
     54    render :text => flash[:notice] || 'no flash' 
    3855  end 
    3956 
     
    7289    assert_equal "Are you there? Yes, ma'am", @response.body 
    7390  end 
     91   
     92  def test_flash 
     93    get :set_flash 
     94    assert_equal 'My stoney baby', flash[:notice] 
     95    get :use_flash 
     96    assert_equal 'My stoney baby', @response.body 
     97    get :use_flash 
     98    assert_equal 'no flash', @response.body 
     99  end 
    74100end