diff options
author | Dan Erikson <derikson3@gmail.com> | 2013-04-08 00:41:16 -0600 |
---|---|---|
committer | Dan Erikson <derikson3@gmail.com> | 2013-04-08 00:41:16 -0600 |
commit | a8ede3664055f33c102b3f229cf280b0bf69c540 (patch) | |
tree | c83e394dbdc279ba21c9d4d11ca243af24482feb /activerecord/lib | |
parent | a92814b001d93f8ef533e692011bbc8824841bf7 (diff) | |
download | rails-a8ede3664055f33c102b3f229cf280b0bf69c540.tar.gz rails-a8ede3664055f33c102b3f229cf280b0bf69c540.tar.bz2 rails-a8ede3664055f33c102b3f229cf280b0bf69c540.zip |
Changed ActiveRecord::Associations::CollectionProxy#select to take multiple arguments.
This makes the arguments the same as ActiveRecord::QueryMethods::select.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 2a00ac1386..5b08d07425 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -67,11 +67,11 @@ module ActiveRecord @target = [] end - def select(select = nil) + def select(*fields) if block_given? load_target.select.each { |e| yield e } else - scope.select(select) + scope.select(*fields) end end diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 8a5b312862..ef2acfce89 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -76,7 +76,7 @@ module ActiveRecord # # #<Pet id: nil, name: "Choo-Choo"> # # ] # - # person.pets.select([:id, :name]) + # person.pets.select(:id, :name ) # # => [ # # #<Pet id: 1, name: "Fancy-Fancy">, # # #<Pet id: 2, name: "Spook">, @@ -107,8 +107,8 @@ module ActiveRecord # # #<Pet id: 2, name: "Spook">, # # #<Pet id: 3, name: "Choo-Choo"> # # ] - def select(select = nil, &block) - @association.select(select, &block) + def select(*fields, &block) + @association.select(*fields, &block) end # Finds an object in the collection responding to the +id+. Uses the same |