diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-02-02 22:26:57 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-02-02 22:26:57 -0800 |
commit | 2259ecf368e6a6715966f69216e3ee86bf1a82a7 (patch) | |
tree | c1beff38bab23fa187615a12c6585ff0c0f68c68 | |
parent | 2ecc678ed6ab60c1bdc7dce67c0c908542c5008d (diff) | |
download | rails-2259ecf368e6a6715966f69216e3ee86bf1a82a7.tar.gz rails-2259ecf368e6a6715966f69216e3ee86bf1a82a7.tar.bz2 rails-2259ecf368e6a6715966f69216e3ee86bf1a82a7.zip |
Don't assume ActiveRecord is available
-rw-r--r-- | actionpack/lib/action_view/partials.rb | 21 |
1 files 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 |