I have a model Asset which has_and_belongs_to_many :tags. Tag has only
one field, name. There is a table assets_tags which only has an
asset_id and a tag_id.
I can add a tag to one asset. If I try to add the same tag to another
asset though (asset.tags << tag) I get this error:
Mysql::Error: #23000Duplicate entry ‘4’ for key 1: INSERT INTO
asset_id) VALUES (4, 4, 1)â†[0m
Any ideas what could be causing that? Why does that table have 3 values
(where does ‘id’ come from) when it’s just a join table? Why does the
tag’s id get assigned to this strange ‘id’ column’s value?
Seriously, I add it like this…
asset.tags << tag