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:
parent
7cc371a032
commit
27f4ffd11a
|
@ -90,13 +90,14 @@ module ActionView
|
|||
|
||||
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 @@ module ActionView
|
|||
[variable, variable_counter]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue