public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Make ActionController#render(string) work as a shortcut for render :action => 
string. [#1435]

Examples:
  # Instead of render(:action => 'other_action')
  render('other_action')

Note : Argument must not have any '/'
lifo (author)
Thu Dec 25 15:01:17 -0800 2008
commit  cd1d6e8768ae13b11bc343701037b20ad35e6f1e
tree    b400f930c3ca31a26c41ab0d30c4283dc17b2d79
parent  d67e03871eabb912434dafac3eeb8e6ea7c5585f
...
1
2
3
 
4
5
6
 
 
7
8
9
10
 
 
 
11
12
13
...
1
2
 
3
4
 
 
5
6
7
8
9
10
11
12
13
14
15
16
0
@@ -1,13 +1,16 @@
0
 *2.3.0 [Edge]*
0
 
0
-* Make ActionController#render(string) work as a shortcut for render :file/:template => string. [#1435] [Pratik Naik] Examples:
0
+* Make ActionController#render(string) work as a shortcut for render :file/:template/:action => string. [#1435] [Pratik Naik] Examples:
0
 
0
-  # Instead of render(:file => '/Users/lifo/home.html.erb')
0
-  render('/Users/lifo/home.html.erb') # argument must begin with a '/'
0
+  # Instead of render(:action => 'other_action')
0
+  render('other_action') # argument has no '/'
0
 
0
   # Instead of render(:template => 'controller/action')
0
   render('controller/action') # argument must not begin with a '/', but contain a '/'
0
 
0
+  # Instead of render(:file => '/Users/lifo/home.html.erb')
0
+  render('/Users/lifo/home.html.erb') # argument must begin with a '/'
0
+
0
 * Add :prompt option to date/time select helpers. #561 [Sam Oliver]
0
 
0
 * Fixed that send_file shouldn't set an etag #1578 [Hongli Lai]
...
866
867
868
869
 
870
871
 
 
872
873
874
...
866
867
868
 
869
870
871
872
873
874
875
876
0
@@ -866,9 +866,11 @@ module ActionController #:nodoc:
0
         elsif options == :update
0
           options = extra_options.merge({ :update => true })
0
         elsif options.is_a?(String)
0
-          case position = options.index('/')
0
+          case options.index('/')
0
           when 0
0
             extra_options[:file] = options
0
+          when nil
0
+            extra_options[:action] = options
0
           else
0
             extra_options[:template] = options
0
           end
...
81
82
83
 
 
 
 
84
85
86
...
296
297
298
 
 
 
 
299
300
301
...
743
744
745
 
 
 
 
 
 
746
747
748
...
1043
1044
1045
 
 
 
 
 
1046
1047
1048
...
81
82
83
84
85
86
87
88
89
90
...
300
301
302
303
304
305
306
307
308
309
...
751
752
753
754
755
756
757
758
759
760
761
762
...
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
0
@@ -81,6 +81,10 @@ class TestController < ActionController::Base
0
     render :action => "hello_world"
0
   end
0
 
0
+  def render_action_hello_world_as_string
0
+    render "hello_world"
0
+  end
0
+
0
   def render_action_hello_world_with_symbol
0
     render :action => :hello_world
0
   end
0
@@ -296,6 +300,10 @@ class TestController < ActionController::Base
0
     render :action => "hello_world", :layout => "standard"
0
   end
0
 
0
+  def layout_test_with_different_layout_and_string_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
@@ -743,6 +751,12 @@ class RenderTest < ActionController::TestCase
0
     assert_template "test/hello_world"
0
   end
0
 
0
+  def test_render_action_hello_world_as_string
0
+    get :render_action_hello_world_as_string
0
+    assert_equal "Hello world!", @response.body
0
+    assert_template "test/hello_world"
0
+  end
0
+
0
   def test_render_action_with_symbol
0
     get :render_action_hello_world_with_symbol
0
     assert_template "test/hello_world"
0
@@ -1043,6 +1057,11 @@ 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
+    get :layout_test_with_different_layout_and_string_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