aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-26 15:31:23 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-26 15:31:23 -0700
commit3b8395a8825962b7ddbcb43a24334e5a5994ffde (patch)
tree8fff2dcabc2699b8f912d0a8fef59ad057b4cae6
parent2ceb16e539d13bb0f130dddd630776ea13ee9597 (diff)
downloadrails-3b8395a8825962b7ddbcb43a24334e5a5994ffde.tar.gz
rails-3b8395a8825962b7ddbcb43a24334e5a5994ffde.tar.bz2
rails-3b8395a8825962b7ddbcb43a24334e5a5994ffde.zip
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.
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb13
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb1
-rw-r--r--actionpack/lib/action_controller/metal/rendering.rb8
3 files changed, 18 insertions, 4 deletions
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)
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index 1db68db20f..e62da0fa70 100644
--- a/actionpack/lib/action_controller/metal/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
@@ -191,6 +191,7 @@ module ActionController #:nodoc:
if format = collector.negotiate_format(request)
_process_format(format)
+ _set_content_type _get_content_type format
response = collector.response
response ? response.call : render({})
else
diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb
index a2d671486d..c8934b367f 100644
--- a/actionpack/lib/action_controller/metal/rendering.rb
+++ b/actionpack/lib/action_controller/metal/rendering.rb
@@ -56,10 +56,12 @@ module ActionController
nil
end
- def _process_format(format)
- super
+ def _get_content_type(rendered_format)
+ self.content_type || super
+ end
- self.content_type ||= format.to_s
+ def _set_content_type(format)
+ self.content_type = format
end
# Normalize arguments by catching blocks and setting them on :update.