私はモデルを以下のように定義しています
class One <Active:Record:Base
{
has_and_belongs_to_many :twos, {:join_table => 'map__ones__twos'}
}
class Two <Active:Record:Base
{
has_and_belongs_to_many :ones, {:join_table => 'map__ones__twos'}
}
2 つの名前属性は、1 つのスコープに対して一意である必要があります。つまり、1 つに属するすべての 2 つには固有の名前が必要です。ここでは、Twoモデルで以下のようなものを指定できません
validates_uniqueness_of :name, :scope => one_id
on_id は 2 の表の列ではないためです。むしろ、one_id と two_id は、テーブルmap_ones_twos (多対多の関係) を介して互いにマップされます。
提案してください