From 2ceb16e539d13bb0f130dddd630776ea13ee9597 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 26 Aug 2015 14:04:04 -0700 Subject: [PATCH] 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 --- actionpack/lib/abstract_controller/rendering.rb | 5 +++-- actionpack/lib/action_controller/metal/rendering.rb | 8 ++------ actionview/lib/action_view/rendering.rb | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 854b07d707..a52aa8e874 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -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. diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 0a005085ba..a2d671486d 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -56,14 +56,10 @@ 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 + self.content_type ||= format.to_s end # Normalize arguments by catching blocks and setting them on :update. diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb index f63c397c5b..8604637da2 100644 --- a/actionview/lib/action_view/rendering.rb +++ b/actionview/lib/action_view/rendering.rb @@ -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