diff options
author | Steven Harman <steven@harmanly.com> | 2016-07-26 11:28:03 -0400 |
---|---|---|
committer | Steven Harman <steven@harmanly.com> | 2016-07-26 11:33:34 -0400 |
commit | 87899cfcf0ada140764acf4393eb862698449f54 (patch) | |
tree | 81aaa29290071f035408bdcdefdb685f058bee11 /actionview/lib | |
parent | e4a4936244988f76318a0b219a3cc0bcdcdf3e30 (diff) | |
download | rails-87899cfcf0ada140764acf4393eb862698449f54.tar.gz rails-87899cfcf0ada140764acf4393eb862698449f54.tar.bz2 rails-87899cfcf0ada140764acf4393eb862698449f54.zip |
Use to_a to pre-buffer the collection
We can safely assume we're not dealing with an infinite collection as
we're about to call `each` on it and collect the results until it
terminates on its own. Given that, `to_a` is implemented by the normal
Array-like objects, and less Array-like objects like `Enumerator` and
`Enumerator::Lazy`.
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/renderer/partial_renderer.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb index c2b6e6a290..7c2e07185c 100644 --- a/actionview/lib/action_view/renderer/partial_renderer.rb +++ b/actionview/lib/action_view/renderer/partial_renderer.rb @@ -403,9 +403,8 @@ module ActionView def collection_from_options if @options.key?(:collection) - collection = @options[:collection] || [] - collection = collection.to_ary if collection.respond_to?(:to_ary) - collection + collection = @options[:collection] + collection ? collection.to_a : [] end end |