Skip to content

Commit b6b6b70

Browse files
committed
Handle the deprecation of render :text
In 4.1 render :text was deprecated and replaced with :plain and :html so we need to conditional define a method to handle the difference.
1 parent 54e3632 commit b6b6b70

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/action_controller/caching/actions.rb

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

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

178178
controller.response_body = body
179179
controller.content_type = Mime[cache_path.extension || :html]
180180
end
181+
182+
if ActionPack::VERSION::STRING < '4.1'
183+
def render_to_string(controller, body)
184+
controller.render_to_string(text: body, layout: true)
185+
end
186+
else
187+
def render_to_string(controller, body)
188+
controller.render_to_string(plain: body, layout: true)
189+
end
190+
end
181191
end
182192

183193
class ActionCachePath

0 commit comments

Comments
 (0)