1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

ask the association for records rather than calling send

This commit is contained in:
Aaron Patterson 2013-09-10 11:54:39 -07:00
parent d68419a88e
commit e64b5da550

View file

@ -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)