Skip to content

Commit f5f7ecc

Browse files
chancancodeeileencodes
authored andcommitted
Revert "Revert "Merge pull request rails#16888 from jejacks0n/render_template""
This reverts commit 585e756. Conflicts: actionview/CHANGELOG.md guides/source/4_2_release_notes.md
1 parent 683d4f7 commit f5f7ecc

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

actionview/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
* Changed the meaning of `render "foo/bar"`.
2+
3+
Previously, calling `render "foo/bar"` in a controller action is equivalent
4+
to `render file: "foo/bar"`. In Rails 4.2, this has been changed to mean
5+
`render template: "foo/bar"` instead. If you need to render a file, please
6+
change your code to use the explicit form (`render file: "foo/bar"`) instead.
7+
8+
*Jeremy Jackson*
9+
10+
* Add support for ARIA attributes in tags.
11+
112
* Fix stripping the digest from the automatically generated img tag alt
213
attribute when assets are handled by Sprockets >=3.0.
314

actionview/lib/action_view/rendering.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _process_format(format, options = {}) #:nodoc:
107107
end
108108

109109
# Normalize args by converting render "foo" to render :action => "foo" and
110-
# render "foo/bar" to render :file => "foo/bar".
110+
# render "foo/bar" to render :template => "foo/bar".
111111
# :api: private
112112
def _normalize_args(action=nil, options={})
113113
options = super(action, options)
@@ -117,7 +117,7 @@ def _normalize_args(action=nil, options={})
117117
options = action
118118
when String, Symbol
119119
action = action.to_s
120-
key = action.include?(?/) ? :file : :action
120+
key = action.include?(?/) ? :template : :action
121121
options[key] = action
122122
else
123123
options[:partial] = action

actionview/test/actionpack/controller/render_test.rb

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,17 @@ def hello_world_file
9191

9292
# :ported:
9393
def render_hello_world
94-
render :template => "test/hello_world"
94+
render "test/hello_world"
9595
end
9696

9797
def render_hello_world_with_last_modified_set
9898
response.last_modified = Date.new(2008, 10, 10).to_time
99-
render :template => "test/hello_world"
99+
render "test/hello_world"
100100
end
101101

102102
# :ported: compatibility
103103
def render_hello_world_with_forward_slash
104-
render :template => "/test/hello_world"
104+
render "/test/hello_world"
105105
end
106106

107107
# :ported:
@@ -111,7 +111,7 @@ def render_template_in_top_directory
111111

112112
# :deprecated:
113113
def render_template_in_top_directory_with_slash
114-
render :template => '/shared'
114+
render '/shared'
115115
end
116116

117117
# :ported:
@@ -159,13 +159,6 @@ def render_file_with_instance_variables
159159
render :file => path
160160
end
161161

162-
# :ported:
163-
def render_file_as_string_with_instance_variables
164-
@secret = 'in the sauce'
165-
path = File.expand_path(File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_ivar'))
166-
render path
167-
end
168-
169162
# :ported:
170163
def render_file_not_using_full_path
171164
@secret = 'in the sauce'
@@ -194,7 +187,7 @@ def render_file_with_locals
194187

195188
def render_file_as_string_with_locals
196189
path = File.expand_path(File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_locals'))
197-
render path, :locals => {:secret => 'in the sauce'}
190+
render file: path, :locals => {:secret => 'in the sauce'}
198191
end
199192

200193
def accessing_request_in_template
@@ -780,12 +773,6 @@ def test_render_file
780773
assert_equal "Hello world!", @response.body
781774
end
782775

783-
# :ported:
784-
def test_render_file_as_string_with_instance_variables
785-
get :render_file_as_string_with_instance_variables
786-
assert_equal "The secret is in the sauce\n", @response.body
787-
end
788-
789776
# :ported:
790777
def test_render_file_not_using_full_path
791778
get :render_file_not_using_full_path

0 commit comments

Comments
 (0)