Skip to content

Commit d962342

Browse files
committed
Fix for Rails 6 Mime lookups
After Rails 5.2, controller content_type contained the default charset causing Mime::LOOKUP not to work. This was addressed by adding a new method called `media_type` which would allow Mime lookups to work.
1 parent 7bddaff commit d962342

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/action_controller/caching/pages.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,13 @@ def cache_page(content = nil, options = nil, gzip = Zlib::BEST_COMPRESSION)
275275
request.path
276276
end
277277

278-
if (type = Mime::LOOKUP[self.content_type]) && (type_symbol = type.symbol).present?
278+
type = if self.respond_to?(:media_type)
279+
Mime::LOOKUP[self.media_type]
280+
else
281+
Mime::LOOKUP[self.content_type]
282+
end
283+
284+
if type && (type_symbol = type.symbol).present?
279285
extension = ".#{type_symbol}"
280286
end
281287

0 commit comments

Comments
 (0)