diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-08-18 00:47:18 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-08-18 05:08:41 +0900 |
commit | 70821dea5ac3e726fa0b81db0fa16c80ff7c897f (patch) | |
tree | 7a90e8d5018b3ff330abfdfac51e53737964b677 /activerecord/lib | |
parent | 6568cfd78c89fe70ac7304d03f8f4825fe0b7c72 (diff) | |
download | rails-70821dea5ac3e726fa0b81db0fa16c80ff7c897f.tar.gz rails-70821dea5ac3e726fa0b81db0fa16c80ff7c897f.tar.bz2 rails-70821dea5ac3e726fa0b81db0fa16c80ff7c897f.zip |
Remove unnecessary `select` method for `CollectionProxy`
Currently `CollectionProxy` inherits `Relation` and `Relation` includes
`QueryMethods`. This method is completely duplicated.
https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/relation/query_methods.rb#L271-L275
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 9 |
2 files changed, 6 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 7c688d663c..0cceb7f53e 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -82,14 +82,6 @@ module ActiveRecord @target = [] end - def select(*fields) - if block_given? - load_target.select.each { |e| yield e } - else - scope.select(*fields) - end - end - def find(*args) if block_given? load_target.find(*args) { |*block_args| yield(*block_args) } diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 36f6c1b9c3..fdc98eeeb9 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -53,6 +53,12 @@ module ActiveRecord @association.loaded? end + ## + # :method: select + # + # :call-seq: + # select(*fields, &block) + # # Works in two ways. # # *First:* Specify a subset of fields to be selected from the result set. @@ -106,9 +112,6 @@ module ActiveRecord # # #<Pet id: 2, name: "Spook">, # # #<Pet id: 3, name: "Choo-Choo"> # # ] - def select(*fields, &block) - @association.select(*fields, &block) - end # Finds an object in the collection responding to the +id+. Uses the same # rules as ActiveRecord::Base.find. Returns ActiveRecord::RecordNotFound |