From 67b2404cf9b2c7e0f86bf0294571ef97391a6dcd Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 26 Mar 2012 22:37:36 +0200 Subject: If partial is rendered in controller, grab format from template Previously `rendered_format` was set only based on mime types passed in Accept header, which was wrong if first type from Accept was different than rendered partial. The fix is to simply move setting rendered_format to the place where template is available and grab format from the template. If it fails we can fallback to formats passed by Accept header. --- actionpack/lib/action_view/renderer/partial_renderer.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb index 232667ec01..d4c652c0d1 100644 --- a/actionpack/lib/action_view/renderer/partial_renderer.rb +++ b/actionpack/lib/action_view/renderer/partial_renderer.rb @@ -257,6 +257,14 @@ module ActionView setup(context, options, block) identifier = (@template = find_partial) ? @template.identifier : @path + @lookup_context.rendered_format ||= begin + if @template && @template.formats.present? + @template.formats.first + else + formats.first + end + end + if @collection instrument(:collection, :identifier => identifier || "collection", :count => @collection.size) do render_collection @@ -316,8 +324,6 @@ module ActionView @block = block @details = extract_details(options) - @lookup_context.rendered_format ||= formats.first - if String === partial @object = options[:object] @path = partial -- cgit v1.2.3