Skip to content

Commit

Permalink
Make collection and collection_from_object methods return an array
Browse files Browse the repository at this point in the history
This transforms for instance scoped objects into arrays and avoid
unneeded queries

[#5958 state:committed]
  • Loading branch information
spastorino committed Nov 13, 2010
1 parent ed62b96 commit b870193
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions actionpack/lib/action_view/render/partials.rb
Expand Up @@ -339,13 +339,14 @@ def render_partial(object = @object)


def collection def collection
if @options.key?(:collection) if @options.key?(:collection)
@options[:collection] || [] collection = @options[:collection]
collection.respond_to?(:to_ary) ? collection.to_ary : []
end end
end end


def collection_from_object def collection_from_object
if @object.respond_to?(:to_ary) if @object.respond_to?(:to_ary)
@object @object.to_ary
end end
end end


Expand Down

0 comments on commit b870193

Please sign in to comment.