diff options
-rw-r--r-- | actionpack/CHANGELOG | 4 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/layout.rb | 10 | ||||
-rw-r--r-- | actionpack/test/controller/new_render_test.rb | 5 |
4 files changed, 10 insertions, 11 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 6597a2b63a..5923f0c6f8 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,10 +1,10 @@ *SVN* -* render(:inline) always defaults to :layout => false. +* render(:layout => true) is a synonym for render(:layout => nil) * Make sure the benchmarking render method always returns the output of the render. -* 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. +* 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. * verify with :redirect_to won't redirect if a redirect or render has already been performed #1350 diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 0e2f87b468..b5983f0e90 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -490,7 +490,7 @@ module ActionController #:nodoc: render(options.merge({ :text => "" })) else - render(options.merge({ :template => default_template_name })) + render(options.merge({ :action => action_name })) end end diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb index 52b02f851d..237e274173 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -220,12 +220,10 @@ module ActionController #:nodoc: private def render_with_a_layout_options(options) return options unless options.is_a?(Hash) - case - when options[:text], options[:partial], options[:nothing], options[:inline] - # by default, :text, :partial, :inline, and :nothing never use a layout - { :layout => false }.merge(options) - else + if options.values_at(:text, :file, :template, :inline, :partial, :nothing).compact.empty? options + else + { :layout => false }.merge(options) end end @@ -236,7 +234,7 @@ module ActionController #:nodoc: case options[:layout] when FalseClass nil - when NilClass + when NilClass, TrueClass active_layout if action_has_layout? else active_layout(options[:layout]) diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index a51bd2a83e..9ec3f283cf 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -78,7 +78,7 @@ class NewRenderTestController < ActionController::Base end def partial_only_with_layout - render :partial => "partial_only", :layout => nil + render :partial => "partial_only", :layout => true end def hello_in_a_string @@ -99,7 +99,7 @@ class NewRenderTestController < ActionController::Base private def determine_layout case action_name - when "layout_test", "rendering_without_layout", + when "hello_world", "layout_test", "rendering_without_layout", "rendering_nothing_on_layout", "render_text_hello_world", "partial_only", "partial_only_with_layout", "accessing_params_in_template", @@ -132,6 +132,7 @@ class NewRenderTest < Test::Unit::TestCase get :hello_world assert_response :success assert_template "test/hello_world" + assert_equal "<html>Hello world!</html>", @response.body end def test_do_with_render |