From 2259ecf368e6a6715966f69216e3ee86bf1a82a7 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 2 Feb 2009 22:26:57 -0800 Subject: Don't assume ActiveRecord is available --- actionpack/lib/action_view/partials.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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 -- cgit v1.2.3