From ef3d6fc1d304dbfed7e49fdf501818891839ef65 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Thu, 9 Mar 2017 10:13:09 +0900 Subject: 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. --- activerecord/lib/active_record/associations/collection_proxy.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/associations') 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 # # # # # ] # - # person.pets.select(:id, :name ) + # person.pets.select(:id, :name) # # => [ # # #, # # #, @@ -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) -- cgit v1.2.3