I have a many to many relationship setup for two tables. I'm using
Rails 1.2.3 with mySQL 5. It is specifying the id column when it
I'm using the Multiple Select Helper(http://ruido-blanco.net/blog/
I have two models, company and categories. They have a many to many
relationship. Each class has the "has_and_belongs_to_many" attribute.
I also created the categories_companies table. I checked the table and
it has an id field with the auto-increment attribute. I created the
tables using migrations.
In the view, I have:
Category.find(:all), :id, :name)
and it generates a list of the categories in this format:
<li><input id="company_category_ids_24" name="company[category_ids]"
type="checkbox" value="24" /><label
for="company_category_ids_24">Sports and Recreation</label></li></ul>
and the controller:
@company.updated_on = Time.now
@company.created_on = Time.now
However, after I save, the categories_companies table has the id being
the same number as the category_id.
So the id did not start at 1, it starts at whichever category was
selected. I'm not sure if this bug is because of something I did or
the plugin code..
This is the server log(NOTE that the id in the categories_companies
table is being specified instead of being ignored like the company
SQL (0.000318) INSERT INTO companies (`created_on`, `name`,
`info`, `updated_on`, `url`, `valid`) VALUES('2007-07-21 18:00:21',
'honda', 'dgf', '2007-07-21 18:00:21', 'dfsq', NULL)
categories_companies Columns (0.002207) SHOW FIELDS FROM
SQL (0.000300) INSERT INTO categories_companies (`id`,
`category_id`, `company_id`) VALUES (22, 22, 1)
categories_companies Columns (0.002360) SHOW FIELDS FROM
SQL (0.000276) INSERT INTO categories_companies (`id`,
`category_id`, `company_id`) VALUES (23, 23, 1)
Any ideas how to fix this?