私は、私は次のエラーを取得しています移行を実行したとき、私はしかし、セットアップにHABTM関係のためのマイグレーションファイルをしようとしている:ここでのRails 3:HABTMの移行、主キーの問題
Primary key is not allowed in a has_and_belongs_to_many join table (parts_vehicles).
は私です移行ファイル(20110111035950_create_parts_vehicles.rb):
class CreatePartsVehiclesJoinTable < ActiveRecord::Migration
def self.up
create_table :parts_vehicles, :id => false do |t|
t.integer :part_id
t.integer :vehicle_id
end
end
def self.down
drop_table :parts_vehicles
end
end
The documentation例が発生してから主キーを無効にする:id => false
を使用することを述べているが、私はまだエラーを取得しています。
正しく見えます。 'rake db:migrate:status'を実行して、この移行が' down'であることを確認してください。 –
はい、正しいです。私はDBを落として移行を再実行したときに作業を開始しました。 –