aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index a617a0fb36..cb2d9e0a79 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -558,11 +558,10 @@ module ActiveRecord
def include_in_memory?(record)
if @reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
- @owner.send(proxy_reflection.through_reflection.name.to_sym).map do |source|
- source_reflection_target = source.send(proxy_reflection.source_reflection.name)
- return true if source_reflection_target.respond_to?(:include?) ? source_reflection_target.include?(record) : source_reflection_target == record
+ @owner.send(proxy_reflection.through_reflection.name.to_sym).any? do |source|
+ target = source.send(proxy_reflection.source_reflection.name)
+ target.respond_to?(:include?) ? target.include?(record) : target == record
end
- false
else
@target.include?(record)
end