Skip to content
Browse files

ask the association for records rather than calling `send`

  • Loading branch information...
1 parent d68419a commit e64b5da550491a94a30e504b85c100e14a461444 @tenderlove tenderlove committed Sep 10, 2013
Showing with 2 additions and 1 deletion.
  1. +2 −1 activerecord/lib/active_record/associations/collection_association.rb
View
3 activerecord/lib/active_record/associations/collection_association.rb
@@ -542,7 +542,8 @@ def fetch_first_or_last_using_find?(args)
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)

0 comments on commit e64b5da

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