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]
This commit is contained in:
Santiago Pastorino 2010-11-13 04:01:10 -02:00
parent 7cc371a032
commit 27f4ffd11a

@ -90,13 +90,14 @@ def render_partial
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
@ -163,4 +164,4 @@ def retrieve_variable(path)
[variable, variable_counter]
end
end
end
end