mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user