aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-09-10 11:54:39 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-09-10 11:54:48 -0700
commite64b5da550491a94a30e504b85c100e14a461444 (patch)
treefb735436783eb97376b2b7370f546dadf7c03b57
parentd68419a88e424e588c2d8decc69874bd00588766 (diff)
downloadrails-e64b5da550491a94a30e504b85c100e14a461444.tar.gz
rails-e64b5da550491a94a30e504b85c100e14a461444.tar.bz2
rails-e64b5da550491a94a30e504b85c100e14a461444.zip
ask the association for records rather than calling `send`
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 228c500f0a..8744a57355 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -542,7 +542,8 @@ module ActiveRecord
def include_in_memory?(record)
if reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
- owner.send(reflection.through_reflection.name).any? { |source|
+ assoc = owner.association(reflection.through_reflection.name)
+ assoc.reader.any? { |source|
target = source.send(reflection.source_reflection.name)
target.respond_to?(:include?) ? target.include?(record) : target == record
} || target.include?(record)