diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-03-09 10:13:09 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-03-09 14:21:27 +0900 |
commit | ef3d6fc1d304dbfed7e49fdf501818891839ef65 (patch) | |
tree | ca24b6ccfe2277aa34821799dc4838f1c8efdfcc /activerecord/lib | |
parent | c741b493409a5d8ae1f2514f73570a014ddc6b57 (diff) | |
download | rails-ef3d6fc1d304dbfed7e49fdf501818891839ef65.tar.gz rails-ef3d6fc1d304dbfed7e49fdf501818891839ef65.tar.bz2 rails-ef3d6fc1d304dbfed7e49fdf501818891839ef65.zip |
Fix select with block doesn't return newly built records in has_many association
The `select` in `QueryMethods` is also an enumerable method.
Enumerable methods with block should delegate to `records` on
`CollectionProxy`, not `scope`.
Fixes #28348.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 55bf2e0ff0..bc2f359c65 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -78,7 +78,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">, @@ -1121,7 +1121,7 @@ module ActiveRecord SpawnMethods, ].flat_map { |klass| klass.public_instance_methods(false) - } - self.public_instance_methods(false) + [:scoping] + } - self.public_instance_methods(false) - [:select] + [:scoping] delegate(*delegate_methods, to: :scope) |