aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG1
-rw-r--r--actionpack/lib/action_controller/base.rb10
-rw-r--r--actionpack/test/controller/render_test.rb11
3 files changed, 16 insertions, 6 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 51afa508df..a8abf48441 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -4,6 +4,7 @@
# Instead of render(:action => 'other_action')
render('other_action') # argument has no '/'
+ render(:other_action)
# Instead of render(:template => 'controller/action')
render('controller/action') # argument must not begin with a '/', but contain a '/'
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index e9c96b0ba4..cb654534af 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -859,14 +859,14 @@ module ActionController #:nodoc:
def render(options = nil, extra_options = {}, &block) #:doc:
raise DoubleRenderError, "Can only render or redirect once per action" if performed?
- validate_render_arguments(options, extra_options)
+ validate_render_arguments(options, extra_options, block_given?)
if options.nil?
return render(:file => default_template, :layout => true)
elsif options == :update
options = extra_options.merge({ :update => true })
- elsif options.is_a?(String)
- case options.index('/')
+ elsif options.is_a?(String) || options.is_a?(Symbol)
+ case options.to_s.index('/')
when 0
extra_options[:file] = options
when nil
@@ -1193,8 +1193,8 @@ module ActionController #:nodoc:
end
end
- def validate_render_arguments(options, extra_options)
- if options && options != :update && !options.is_a?(String) && !options.is_a?(Hash)
+ def validate_render_arguments(options, extra_options, has_block)
+ if options && (has_block && options != :update) && !options.is_a?(String) && !options.is_a?(Hash) && !options.is_a?(Symbol)
raise RenderError, "You called render with invalid options : #{options.inspect}"
end
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index d097cf496f..5fd41d8eec 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -304,6 +304,10 @@ class TestController < ActionController::Base
render "hello_world", :layout => "standard"
end
+ def layout_test_with_different_layout_and_symbol_action
+ render :hello_world, :layout => "standard"
+ end
+
def rendering_without_layout
render :action => "hello_world", :layout => false
end
@@ -1057,11 +1061,16 @@ class RenderTest < ActionController::TestCase
assert_equal "<html>Hello world!</html>", @response.body
end
- def test_layout_test_with_different_layout
+ def test_layout_test_with_different_layout_and_string_action
get :layout_test_with_different_layout_and_string_action
assert_equal "<html>Hello world!</html>", @response.body
end
+ def test_layout_test_with_different_layout_and_symbol_action
+ get :layout_test_with_different_layout_and_symbol_action
+ assert_equal "<html>Hello world!</html>", @response.body
+ end
+
def test_rendering_without_layout
get :rendering_without_layout
assert_equal "Hello world!", @response.body