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

Changeset 1378

Show
Ignore:
Timestamp:
06/01/05 13:39:58 (3 years ago)
Author:
minam
Message:

render(:action) and render() are the only two render calls to use a layout by default. All others default to :layout => false. Also, allow :layout => true to be a synonym for :layout => nil.

Files:

Legend:

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

    r1372 r1378  
    11*SVN* 
    22 
    3 * render(:inline) always defaults to :layout => false. 
     3* render(:layout => true) is a synonym for render(:layout => nil) 
    44 
    55* Make sure the benchmarking render method always returns the output of the render. 
    66 
    7 * render(:text), render(:partial), and render(:nothing) always default to :layout => false. This also fixes send_file, which was applying a layout if one existed for the current action. 
     7* render(:action) and render() are the only two calls that default to using a layout. All other render calls assume :layout => false. This also fixes send_file, which was applying a layout if one existed for the current action. 
    88 
    99* verify with :redirect_to won't redirect if a redirect or render has already been performed #1350 
  • trunk/actionpack/lib/action_controller/base.rb

    r1366 r1378  
    491491 
    492492        else 
    493           render(options.merge({ :template => default_template_name })) 
     493          render(options.merge({ :action => action_name })) 
    494494        end 
    495495      end 
  • trunk/actionpack/lib/action_controller/layout.rb

    r1372 r1378  
    221221      def render_with_a_layout_options(options) 
    222222        return options unless options.is_a?(Hash) 
    223         case 
    224         when options[:text], options[:partial], options[:nothing], options[:inline] 
    225           # by default, :text, :partial, :inline, and :nothing never use a layout 
     223        if options.values_at(:text, :file, :template, :inline, :partial, :nothing).compact.empty? 
     224          options 
     225        else 
    226226          { :layout => false }.merge(options) 
    227         else 
    228           options 
    229227        end 
    230228      end 
     
    237235            when FalseClass 
    238236              nil 
    239             when NilClass 
     237            when NilClass, TrueClass 
    240238              active_layout if action_has_layout? 
    241239            else 
  • trunk/actionpack/test/controller/new_render_test.rb

    r1372 r1378  
    7979 
    8080  def partial_only_with_layout 
    81     render :partial => "partial_only", :layout => nil 
     81    render :partial => "partial_only", :layout => true 
    8282  end 
    8383 
     
    100100    def determine_layout 
    101101      case action_name  
    102         when "layout_test", "rendering_without_layout", 
     102        when "hello_world", "layout_test", "rendering_without_layout", 
    103103             "rendering_nothing_on_layout", "render_text_hello_world", 
    104104             "partial_only", "partial_only_with_layout", 
     
    133133    assert_response :success 
    134134    assert_template "test/hello_world" 
     135    assert_equal "<html>Hello world!</html>", @response.body 
    135136  end 
    136137