I would like to define a unique key for records based on 2 columns : \'id\' and \'language\'
to let the user submits the following strings : id=1 language=en value=bl
Model
class User < ActiveRecord::Base
has_secure_password
self.primary_keys = :name
end
Migration
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name, null: false
t.string :emailid
t.string :password_digest
t.integer :locked, :default => 0
t.text :secretquestion
t.string :answer
t.timestamps null: false
end
add_index :users, :name, :unique => true
end
end
You will get this table