aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-03-18 18:17:34 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-03-20 18:49:14 +0900
commit1385a8b5ff81adc3dfa5dc6ad88ce00b28e95ce1 (patch)
treef967c315d6d4281cbdde13b2481126d20fc4f89c /activerecord/test/models
parent1835d87fb848fd9f13e43bf16abd41be231b1666 (diff)
downloadrails-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/test/models')
-rw-r--r--activerecord/test/models/post.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index e74aedb814..a2028b3eb9 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -59,6 +59,10 @@ class Post < ActiveRecord::Base
def the_association
proxy_association
end
+
+ def with_content(content)
+ self.detect { |comment| comment.body == content }
+ end
end
has_many :comments_with_extend, extend: NamedExtension, class_name: "Comment", foreign_key: "post_id" do