diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2012-03-26 22:37:36 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2012-03-27 12:14:56 +0200 |
commit | 67b2404cf9b2c7e0f86bf0294571ef97391a6dcd (patch) | |
tree | 9af9c8c3b057426cc13448d0c8e9769d1eeb60d3 /actionpack/lib/action_view | |
parent | 19901c6c61d1900a1452c8b14943a8345463f039 (diff) | |
download | rails-67b2404cf9b2c7e0f86bf0294571ef97391a6dcd.tar.gz rails-67b2404cf9b2c7e0f86bf0294571ef97391a6dcd.tar.bz2 rails-67b2404cf9b2c7e0f86bf0294571ef97391a6dcd.zip |
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.
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/renderer/partial_renderer.rb | 10 |
1 files changed, 8 insertions, 2 deletions
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 |