diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-03-18 18:17:34 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-03-20 18:49:14 +0900 |
commit | 1385a8b5ff81adc3dfa5dc6ad88ce00b28e95ce1 (patch) | |
tree | f967c315d6d4281cbdde13b2481126d20fc4f89c /activerecord/lib/active_record | |
parent | 1835d87fb848fd9f13e43bf16abd41be231b1666 (diff) | |
download | rails-1385a8b5ff81adc3dfa5dc6ad88ce00b28e95ce1.tar.gz rails-1385a8b5ff81adc3dfa5dc6ad88ce00b28e95ce1.tar.bz2 rails-1385a8b5ff81adc3dfa5dc6ad88ce00b28e95ce1.zip |
Fix extension method with dirty target in has_many associations
Extension methods should not delegate to `scope` to respect dirty
target on `CollectionProxy`.
Fixes #28419.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index bc2f359c65..3c44296d8c 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -1154,8 +1154,9 @@ module ActiveRecord end def method_missing(method, *args, &block) - if scope.respond_to?(method) - scope.public_send(method, *args, &block) + if scope.respond_to?(method) && scope.extending_values.any? + extend(*scope.extending_values) + public_send(method, *args, &block) else super end |