From 48bc8696eaebd35884a31b37a50c46ee742e4711 Mon Sep 17 00:00:00 2001 From: bollard Date: Thu, 30 Oct 2014 14:27:20 +0000 Subject: [PATCH] Delegate to visit instead of calling `.id` directly This is related to #348 Translation of an ActiveRecord::Base object to an integer should be defined once (i.e. in visit_ActiveRecord_base). This makes it easier for the case when a user does not want to query by `id` but some other field, for example `persistent_id` --- lib/squeel/visitors/predicate_visitor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 << [