Converting join table to join model table

I have a join table (foos_bars) which used to just be a join table in a HABTM relationship.

Now I want to create a FooBars model to hold extra attributes about the relationship without losing any of the data in the table, however I can't think of a way to add the promary key column without an error. How do I do it?


doesn't rails add an id column anyway?

A HABTM association doesn't use an id primary key in the table definition. The structure is similar to:

table 'table1_table2'   t.column table1_id, :integer   t.column table2_id, :integer

Since you're now stating you want the join to be pushed to a separate model now, with attributes; you'll change both model definitions to have has_many :myNewJoinyThing. The model will also have the same association. Since it is a separate model you can add attributes as well.

Gareth Adams wrote: