Bad rails day for Matt-
In a migration, for a habtm:
create_table :teams_users do |t|
t.column :team_id, :integer
t.column :user_id, :integer
end
Ok, fine. In a controller (well really a migration script):
@user.teams << Team.find( 3 )
And the SQL pumped at my server is:
INSERT INTO teams_users (team_id
, id
, user_id
) VALUES (3, 3, 34)
Which promptly fails, because the id column already has a row with the
id of 3. I see one immediate solution:
- after create_table, remove_column :teams_users, ‘id’. If that’s even
legal. Would be nice if create_table had it as an option to not make an
ID column, but this’ll do.
But that seems sort of hackneyed. Is is a bug that the ID column is
being manually populated by rails? Doesn’t seem very senseble,
especially if the content of ID is always the same as team_id. Bug?
Feature?
–
Matthew B. :: [email protected]
Resume & Portfolio @ http://madhatted.com