1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
Aaron Patterson 2015-08-26 15:31:23 -07:00
parent 2ceb16e539
commit 3b8395a882
3 changed files with 18 additions and 4 deletions

View file

@ -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)

View file

@ -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

View file

@ -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.