diff --git a/active_record/associations/through_association_scope.rb b/active_record/associations/through_association_scope.rb index 1d2f323..8f69b48 100644 --- a/active_record/associations/through_association_scope.rb +++ b/active_record/associations/through_association_scope.rb @@ -34,7 +34,7 @@ module ActiveRecord @owner.class.base_class.name.to_s, reflection.klass.columns_hash["#{as}_type"]) } elsif reflection.macro == :belongs_to - { reflection.klass.primary_key => @owner[reflection.primary_key_name] } + { reflection.klass.primary_key => @owner.class.quote_value(@owner[reflection.primary_key_name]) } else { reflection.primary_key_name => owner_quoted_id } end