lib/rabl/partials.rb in rabl-0.6.14 vs lib/rabl/partials.rb in rabl-0.7.0
- old
+ new
@@ -69,10 +69,13 @@
if source_format && context_scope.respond_to?(:lookup_context) # Rails 3
lookup_proc = lambda { |partial|
if ActionPack::VERSION::MAJOR == 3 && ActionPack::VERSION::MINOR < 2
context_scope.lookup_context.find(file, [], partial)
else # Rails 3.2 and higher
- context_scope.lookup_context.find(file, [], partial, [], {:formats => [:json]})
+ # pull format directly from rails unless it is html
+ rendered_format = context_scope.lookup_context.rendered_format
+ source_format = rendered_format unless rendered_format == :html
+ context_scope.lookup_context.find(file, [], partial, [], {:formats => [source_format]})
end }
template = lookup_proc.call(false) rescue lookup_proc.call(true)
template.identifier if template
elsif source_format && context_scope.respond_to?(:view_paths) # Rails 2
template = context_scope.view_paths.find_template(file, source_format, false)