我想为基于两列的记录定义一个唯一键:"id"和"language"
要让用户提交以下字符串:
I tried to use set_primary_key and also add_index but it didn't work ( add_index :words, ["id", "language_id"], :unique => true )
我有以下型号:
class Word < ActiveRecord::Base
belongs_to :dictionnary
belongs_to :language
attr_accessible :lang, :rev, :value, :dictionnary_id, :language_id
validates :value, :uniqueness => true
end
还有这个
class Language < ActiveRecord::Base
has_many :words
attr_accessible :lang
end