Skip to content

Commit 9dd3a71

Browse files
eileencodespixeltrix
authored andcommitted
Fix render text deprecation warning
`render text:` is no longer a valid way to render just text content. The correct way is to use `render plain:`. `render text:` is deprecated.
1 parent 8d5bab7 commit 9dd3a71

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/action_controller/caching/actions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def around(controller)
173173
body = controller._save_fragment(cache_path.path, @store_options)
174174
end
175175

176-
body = controller.render_to_string(text: body, layout: true) unless cache_layout
176+
body = controller.render_to_string(plain: body, layout: true) unless cache_layout
177177

178178
controller.response_body = body
179179
controller.content_type = Mime[cache_path.extension || :html]

test/caching_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,27 @@ class ActionCachingTestController < CachingController
5050

5151
def index
5252
@cache_this = MockTime.now.to_f.to_s
53-
render text: @cache_this
53+
render plain: @cache_this
5454
end
5555

5656
def redirected
5757
redirect_to action: 'index'
5858
end
5959

6060
def forbidden
61-
render text: 'Forbidden'
61+
render plain: 'Forbidden'
6262
response.status = '403 Forbidden'
6363
end
6464

6565
def with_layout
6666
@cache_this = MockTime.now.to_f.to_s
6767
@title = nil
68-
render text: @cache_this, layout: true
68+
render plain: @cache_this, layout: true
6969
end
7070

7171
def with_format_and_http_param
7272
@cache_this = MockTime.now.to_f.to_s
73-
render text: @cache_this
73+
render plain: @cache_this
7474
end
7575

7676
def with_symbol_format
@@ -87,7 +87,7 @@ def record_not_found
8787
end
8888

8989
def four_oh_four
90-
render text: "404'd!", status: 404
90+
render plain: "404'd!", status: 404
9191
end
9292

9393
def simple_runtime_error
@@ -118,7 +118,7 @@ def expire_with_url_string
118118
end
119119

120120
def streaming
121-
render text: 'streaming', stream: true
121+
render plain: 'streaming', stream: true
122122
end
123123

124124
def invalid

0 commit comments

Comments
 (0)