Browse files

Don't assume ActiveRecord is available

  • Loading branch information...
1 parent 2ecc678 commit 2259ecf368e6a6715966f69216e3ee86bf1a82a7 @jeremy jeremy committed Feb 2, 2009
Showing with 13 additions and 8 deletions.
  1. +13 −8 actionpack/lib/action_view/partials.rb
View
21 actionpack/lib/action_view/partials.rb
@@ -187,15 +187,20 @@ def render_partial(options = {}) #:nodoc:
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

0 comments on commit 2259ecf

Please sign in to comment.