Skip to content
This repository
Browse code

ask the association for records rather than calling `send`

  • Loading branch information...
commit e64b5da550491a94a30e504b85c100e14a461444 1 parent d68419a
Aaron Patterson tenderlove authored
3  activerecord/lib/active_record/associations/collection_association.rb
@@ -542,7 +542,8 @@ def fetch_first_or_last_using_find?(args)
542 542
543 543 def include_in_memory?(record)
544 544 if reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
545   - owner.send(reflection.through_reflection.name).any? { |source|
  545 + assoc = owner.association(reflection.through_reflection.name)
  546 + assoc.reader.any? { |source|
546 547 target = source.send(reflection.source_reflection.name)
547 548 target.respond_to?(:include?) ? target.include?(record) : target == record
548 549 } || target.include?(record)

0 comments on commit e64b5da

Please sign in to comment.
Something went wrong with that request. Please try again.