public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Make ActionController#render(symbol) behave same as 
ActionController#render(string) [#1435]
lifo (author)
Thu Dec 25 17:03:18 -0800 2008
commit  80307c8b0a889acc7abb7f4e52fd4c02e1063ba8
tree    c4cb570b8f29a63408c3b74f2cbedd383c48d237
parent  cd1d6e8768ae13b11bc343701037b20ad35e6f1e
...
4
5
6
 
7
8
9
...
4
5
6
7
8
9
10
0
@@ -4,6 +4,7 @@
0
 
0
   # Instead of render(:action => 'other_action')
0
   render('other_action') # argument has no '/'
0
+  render(:other_action)
0
 
0
   # Instead of render(:template => 'controller/action')
0
   render('controller/action') # argument must not begin with a '/', but contain a '/'
...
859
860
861
862
 
863
864
865
866
867
868
869
 
 
870
871
872
...
1193
1194
1195
1196
1197
 
 
1198
1199
1200
...
859
860
861
 
862
863
864
865
866
867
 
 
868
869
870
871
872
...
1193
1194
1195
 
 
1196
1197
1198
1199
1200
0
@@ -859,14 +859,14 @@ module ActionController #:nodoc:
0
       def render(options = nil, extra_options = {}, &block) #:doc:
0
         raise DoubleRenderError, "Can only render or redirect once per action" if performed?
0
 
0
-        validate_render_arguments(options, extra_options)
0
+        validate_render_arguments(options, extra_options, block_given?)
0
 
0
         if options.nil?
0
           return render(:file => default_template, :layout => true)
0
         elsif options == :update
0
           options = extra_options.merge({ :update => true })
0
-        elsif options.is_a?(String)
0
-          case options.index('/')
0
+        elsif options.is_a?(String) || options.is_a?(Symbol)
0
+          case options.to_s.index('/')
0
           when 0
0
             extra_options[:file] = options
0
           when nil
0
@@ -1193,8 +1193,8 @@ module ActionController #:nodoc:
0
         end
0
       end
0
 
0
-      def validate_render_arguments(options, extra_options)
0
-        if options && options != :update && !options.is_a?(String) && !options.is_a?(Hash)
0
+      def validate_render_arguments(options, extra_options, has_block)
0
+        if options && (has_block && options != :update) && !options.is_a?(String) && !options.is_a?(Hash) && !options.is_a?(Symbol)
0
           raise RenderError, "You called render with invalid options : #{options.inspect}"
0
         end
0
 
...
304
305
306
 
 
 
 
307
308
309
...
1057
1058
1059
1060
 
1061
1062
1063
1064
 
 
 
 
 
1065
1066
1067
...
304
305
306
307
308
309
310
311
312
313
...
1061
1062
1063
 
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
0
@@ -304,6 +304,10 @@ class TestController < ActionController::Base
0
     render "hello_world", :layout => "standard"
0
   end
0
 
0
+  def layout_test_with_different_layout_and_symbol_action
0
+    render :hello_world, :layout => "standard"
0
+  end
0
+
0
   def rendering_without_layout
0
     render :action => "hello_world", :layout => false
0
   end
0
@@ -1057,11 +1061,16 @@ class RenderTest < ActionController::TestCase
0
     assert_equal "<html>Hello world!</html>", @response.body
0
   end
0
 
0
-  def test_layout_test_with_different_layout
0
+  def test_layout_test_with_different_layout_and_string_action
0
     get :layout_test_with_different_layout_and_string_action
0
     assert_equal "<html>Hello world!</html>", @response.body
0
   end
0
 
0
+  def test_layout_test_with_different_layout_and_symbol_action
0
+    get :layout_test_with_different_layout_and_symbol_action
0
+    assert_equal "<html>Hello world!</html>", @response.body
0
+  end
0
+
0
   def test_rendering_without_layout
0
     get :rendering_without_layout
0
     assert_equal "Hello world!", @response.body

Comments

iownbey Thu Dec 25 23:47:12 -0800 2008

Thank jesus