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

Pull plain content type handling up to render

`render` is the only possible source for the `plain` option.  Pulling
the conditional up to the `render` method removes far away conditionals
This commit is contained in:
Aaron Patterson 2015-08-26 14:04:04 -07:00
parent fa09bf44db
commit 2ceb16e539
3 changed files with 6 additions and 9 deletions

View file

@ -23,7 +23,8 @@ module AbstractController
def render(*args, &block)
options = _normalize_render(*args, &block)
self.response_body = render_to_body(options)
_process_format(rendered_format, options[:plain]) if rendered_format
_process_format(rendered_format) if rendered_format
self.content_type = Mime::TEXT if options[:plain]
self.response_body
end
@ -99,7 +100,7 @@ module AbstractController
# Process the rendered format.
# :api: private
def _process_format(format, plain = false)
def _process_format(format)
end
# Normalize args and options.

View file

@ -56,15 +56,11 @@ module ActionController
nil
end
def _process_format(format, plain = false)
def _process_format(format)
super
if plain
self.content_type = Mime::TEXT
else
self.content_type ||= format.to_s
end
end
# Normalize arguments by catching blocks and setting them on :update.
def _normalize_args(action=nil, options={}, &blk) #:nodoc:

View file

@ -104,7 +104,7 @@ module ActionView
end
# Assign the rendered format to look up context.
def _process_format(format, plain = false) #:nodoc:
def _process_format(format) #:nodoc:
super
lookup_context.formats = [format.to_sym]
lookup_context.rendered_format = lookup_context.formats.first