diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb index 59e82b98a4..9e5e0f786e 100644 --- a/actionpack/lib/action_view/partials.rb +++ b/actionpack/lib/action_view/partials.rb @@ -187,15 +187,20 @@ module ActionView builder_partial_path = partial_path.class.to_s.demodulize.underscore.sub(/_builder$/, '') local_assigns.merge!(builder_partial_path.to_sym => partial_path) render_partial(:partial => builder_partial_path, :object => options[:object], :locals => local_assigns) - when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::NamedScope::Scope - render_partial_collection(options.except(:partial).merge(:collection => partial_path)) else - object = partial_path - render_partial( - :partial => ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path), - :object => object, - :locals => local_assigns - ) + if Array === partial_path || + (defined?(ActiveRecord) && + (ActiveRecord::Associations::AssociationCollection === partial_path || + ActiveRecord::NamedScope::Scope === partial_path)) + render_partial_collection(options.except(:partial).merge(:collection => partial_path)) + else + object = partial_path + render_partial( + :partial => ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path), + :object => object, + :locals => local_assigns + ) + end end end