I am using rails and SQL server in a project. When I put the following validation in the model: validates :Clave, uniqueness: true
I get this error: can't cast ActiveRecord::ConnectionAdapters::SQLServer::Type::Char::Data to varchar
this is my schema.rb
create_table "Productos", primary_key: "Clave", force: :cascade do |t|
t.integer "Id", limit: 4, null: false
t.varchar "Producto", limit: 255
t.varchar "CodBarras", limit: 50
t.varchar "IdEmpresa", limit: 50
end
this is my model producto.rb
class Producto < ActiveRecord::Base
self.primary_key = "Clave"
validates :IdEmpresa, uniqueness: true
validates :Clave, uniqueness: true
validates :Producto, presence: true
end