aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
Diffstat (limited to 'actionview')
-rw-r--r--actionview/CHANGELOG.md10
-rw-r--r--actionview/lib/action_view/renderer/partial_renderer.rb5
2 files changed, 7 insertions, 8 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md
index 987d062540..7754bd8dd9 100644
--- a/actionview/CHANGELOG.md
+++ b/actionview/CHANGELOG.md
@@ -1,11 +1,11 @@
* Changed partial rendering with a collection to allow collections which
- don't implement `to_ary`.
+ implement `to_a`.
- Extracting the collection option has an optimization to avoid unnecessary
- queries of ActiveRecord Relations by calling `to_ary` on the given
+ Extracting the collection option had an optimization to avoid unnecessary
+ queries of ActiveRecord Relations by calling `#to_ary` on the given
collection. Instances of `Enumerator` or `Enumerable` are valid
- collections, but they do not implement `#to_ary`. They will now be
- extracted and rendered as expected.
+ collections, but they do not implement `#to_ary`. By changing this to
+ `#to_a`, they will now be extracted and rendered as expected.
*Steven Harman*
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