aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2010-11-13 04:01:10 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2010-11-13 04:02:57 -0200
commit27f4ffd11a91b534fde9b484cb7c4e515ec0fe77 (patch)
tree4da3953c3dc9eb1b37e05b81572abb4cfb99560b /actionpack
parent7cc371a032214afbfab94e756d82a3058e3a7e02 (diff)
downloadrails-27f4ffd11a91b534fde9b484cb7c4e515ec0fe77.tar.gz
rails-27f4ffd11a91b534fde9b484cb7c4e515ec0fe77.tar.bz2
rails-27f4ffd11a91b534fde9b484cb7c4e515ec0fe77.zip
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]
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/renderer/partial_renderer.rb7
1 files 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