From 3b8395a8825962b7ddbcb43a24334e5a5994ffde Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 26 Aug 2015 15:31:23 -0700 Subject: only call self.content_type= when there is a response Apparently the AbstractController (whatever "abstract" means) is expected to work without a request and response. --- actionpack/lib/abstract_controller/rendering.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/abstract_controller/rendering.rb') diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index a52aa8e874..765db74b2b 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -24,7 +24,11 @@ module AbstractController options = _normalize_render(*args, &block) self.response_body = render_to_body(options) _process_format(rendered_format) if rendered_format - self.content_type = Mime::TEXT if options[:plain] + if options[:plain] + _set_content_type Mime::TEXT.to_s + else + _set_content_type _get_content_type(rendered_format) + end self.response_body end @@ -103,6 +107,13 @@ module AbstractController def _process_format(format) end + def _get_content_type(rendered_format) # :nodoc: + rendered_format.to_s + end + + def _set_content_type(type) # :nodoc: + end + # Normalize args and options. # :api: private def _normalize_render(*args, &block) -- cgit v1.2.3