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:
parent
fa09bf44db
commit
2ceb16e539
3 changed files with 6 additions and 9 deletions
|
@ -23,7 +23,8 @@ module AbstractController
|
||||||
def render(*args, &block)
|
def render(*args, &block)
|
||||||
options = _normalize_render(*args, &block)
|
options = _normalize_render(*args, &block)
|
||||||
self.response_body = render_to_body(options)
|
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
|
self.response_body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -99,7 +100,7 @@ module AbstractController
|
||||||
|
|
||||||
# Process the rendered format.
|
# Process the rendered format.
|
||||||
# :api: private
|
# :api: private
|
||||||
def _process_format(format, plain = false)
|
def _process_format(format)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Normalize args and options.
|
# Normalize args and options.
|
||||||
|
|
|
@ -56,14 +56,10 @@ module ActionController
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def _process_format(format, plain = false)
|
def _process_format(format)
|
||||||
super
|
super
|
||||||
|
|
||||||
if plain
|
self.content_type ||= format.to_s
|
||||||
self.content_type = Mime::TEXT
|
|
||||||
else
|
|
||||||
self.content_type ||= format.to_s
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Normalize arguments by catching blocks and setting them on :update.
|
# Normalize arguments by catching blocks and setting them on :update.
|
||||||
|
|
|
@ -104,7 +104,7 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
# Assign the rendered format to look up context.
|
# Assign the rendered format to look up context.
|
||||||
def _process_format(format, plain = false) #:nodoc:
|
def _process_format(format) #:nodoc:
|
||||||
super
|
super
|
||||||
lookup_context.formats = [format.to_sym]
|
lookup_context.formats = [format.to_sym]
|
||||||
lookup_context.rendered_format = lookup_context.formats.first
|
lookup_context.rendered_format = lookup_context.formats.first
|
||||||
|
|
Loading…
Reference in a new issue