aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-03-26 22:37:36 +0200
committerPiotr Sarnacki <drogus@gmail.com>2012-03-27 05:33:47 +0200
commit449a4fc0957748bca3bddf6a15e4d2ae72e2898f (patch)
tree28e94d43197fa0e4f18368ad5d17f8b0820232c4 /actionpack/lib/action_view
parent3eb5be67b14e347951eea2dd13cd6f4a8aaaa38c (diff)
downloadrails-449a4fc0957748bca3bddf6a15e4d2ae72e2898f.tar.gz
rails-449a4fc0957748bca3bddf6a15e4d2ae72e2898f.tar.bz2
rails-449a4fc0957748bca3bddf6a15e4d2ae72e2898f.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.rb10
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 17aa85555c..25c41f042b 100644
--- a/actionpack/lib/action_view/renderer/partial_renderer.rb
+++ b/actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -221,6 +221,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
@@ -273,8 +281,6 @@ module ActionView
@block = block
@details = extract_details(options)
- @lookup_context.rendered_format ||= formats.first
-
if String === partial
@object = options[:object]
@path = partial