diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2013-09-09 12:32:39 -0300 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2013-09-09 12:33:53 -0300 |
commit | 67336ce199d4eece2f6047a13e692c356e5caa97 (patch) | |
tree | f43f02baf987902a6b23d0edd5fc8207e1df20da | |
parent | a41669563b960d604068013a5b808476391b1cb9 (diff) | |
download | rails-67336ce199d4eece2f6047a13e692c356e5caa97.tar.gz rails-67336ce199d4eece2f6047a13e692c356e5caa97.tar.bz2 rails-67336ce199d4eece2f6047a13e692c356e5caa97.zip |
Remove remaining coupling with AV in MimeResponds
4 files changed, 20 insertions, 5 deletions
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 575b9807d0..242c44a6eb 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -32,6 +32,8 @@ module AbstractController def render(*args, &block) options = _normalize_render(*args, &block) self.response_body = render_to_body(options) + _process_format(rendered_format) + self.response_body end # Raw rendering of a template to a string. @@ -98,6 +100,11 @@ module AbstractController options end + # Process the rendered format. + # :api: private + def _process_format(format) + 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 834d44f045..66dabd821f 100644 --- a/actionpack/lib/action_controller/metal/mime_responds.rb +++ b/actionpack/lib/action_controller/metal/mime_responds.rb @@ -364,9 +364,7 @@ module ActionController #:nodoc: format = collector.negotiate_format(request) if format - self.content_type ||= format.to_s - lookup_context.formats = [format.to_sym] - lookup_context.rendered_format = lookup_context.formats.first + _process_format(format) collector else raise ActionController::UnknownFormat diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 37dee1738f..90f0ef0b1c 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -12,8 +12,6 @@ module ActionController def render(*args) #:nodoc: raise ::AbstractController::DoubleRenderError if self.response_body super - self.content_type ||= rendered_format.to_s - self.response_body end # Overwrite render_to_string because body can now be set to a rack body. @@ -38,6 +36,11 @@ module ActionController private + def _process_format(format) + super + self.content_type ||= format.to_s + end + # Normalize arguments by catching blocks and setting them on :update. def _normalize_args(action=nil, options={}, &blk) #:nodoc: options = super diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb index e0486ba596..18a0788f8e 100644 --- a/actionview/lib/action_view/rendering.rb +++ b/actionview/lib/action_view/rendering.rb @@ -95,6 +95,13 @@ module ActionView private + # Assign the rendered format to lookup context. + def _process_format(format) #:nodoc: + super + lookup_context.formats = [format.to_sym] + lookup_context.rendered_format = lookup_context.formats.first + end + # Normalize args by converting render "foo" to render :action => "foo" and # render "foo/bar" to render :file => "foo/bar". # :api: private |