diff --git a/lib/squeel/visitors/predicate_visitor.rb b/lib/squeel/visitors/predicate_visitor.rb index d546193..67ee1cb 100644 --- a/lib/squeel/visitors/predicate_visitor.rb +++ b/lib/squeel/visitors/predicate_visitor.rb @@ -21,7 +21,7 @@ def expand_belongs_to(o, parent, association) context = contextualize(parent) ar_base = o.value conditions = [ - context[association.foreign_key.to_s].send(o.method_name, ar_base.id) + context[association.foreign_key.to_s].send(o.method_name, visit(ar_base, parent)) ] if association.options[:polymorphic] conditions << [