diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-10 11:54:39 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-10 11:54:48 -0700 |
commit | e64b5da550491a94a30e504b85c100e14a461444 (patch) | |
tree | fb735436783eb97376b2b7370f546dadf7c03b57 | |
parent | d68419a88e424e588c2d8decc69874bd00588766 (diff) | |
download | rails-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.rb | 3 |
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) |