Rails 3: habtm migration, primary key issue
Posted
by
Brian Wigginton
on Stack Overflow
See other posts from Stack Overflow
or by Brian Wigginton
Published on 2011-01-11T04:48:13Z
Indexed on
2011/01/11
4:53 UTC
Read the original article
Hit count: 251
I'm trying to setup a migration file for a habtm relationship, however when I run the migration I'm getting the following error:
Primary key is not allowed in a has_and_belongs_to_many join table (parts_vehicles).
Here is my migration file (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 example states to use :id => false
to disable a primary key from being generated, but I'm still getting the error.
© Stack Overflow or respective owner