Permalink
Browse files

Make collection and collection_from_object methods return an array

This transforms for instance scoped objects into arrays and avoid
unneeded queries

[#5958 state:committed]
  • Loading branch information...
1 parent ed62b96 commit b8701933453c82bdb968532bdd7dee8cec775b72 @spastorino spastorino committed Nov 13, 2010
Showing with 3 additions and 2 deletions.
  1. +3 −2 actionpack/lib/action_view/render/partials.rb
@@ -339,13 +339,14 @@ def render_partial(object = @object)
def collection
if @options.key?(:collection)
- @options[:collection] || []
+ collection = @options[:collection]
+ collection.respond_to?(:to_ary) ? collection.to_ary : []
end
end
def collection_from_object
if @object.respond_to?(:to_ary)
- @object
+ @object.to_ary
end
end

0 comments on commit b870193

Please sign in to comment.