From 27f4ffd11a91b534fde9b484cb7c4e515ec0fe77 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sat, 13 Nov 2010 04:01:10 -0200 Subject: 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] --- actionpack/lib/action_view/renderer/partial_renderer.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb index c580397cad..317479ad4c 100644 --- a/actionpack/lib/action_view/renderer/partial_renderer.rb +++ b/actionpack/lib/action_view/renderer/partial_renderer.rb @@ -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 \ No newline at end of file +end -- cgit v1.2.3