Acts As Taggable gem and MySQL duplicate key

I was using acts_as_taggable DHH’s plugin. But I have moved to gem based one. After changing my database scheme and making code changes I ran across issue. When I was updating routes with tags ActiveRecord have dumped following error:
ActiveRecord::StatementInvalid (Mysql::Error: Duplicate entry '9' for key 1: INSERT INTO routes_tags (`tag_id`, `id`, `route_id`) VALUES (9, 9, 46)):

I was digging two nights and… long story short – there has to be no primary index on table holding bindings between tags and objects (here: routes_tags table).

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.