mbleigh/acts-as-taggable-on — Issue #206: Multiple tags with the same name are being created
Author: mstump
Created: 2011-12-04 07:07:48+00:00
State: open

I'm using version 2.1.1

acts-as-taggable-on is creating multiple tags with the same name. For example I had 4 tags all with the name 'Debian'. Often the same object is tagged once by each of these duplicates so one of my objects may have 4 'Debian' tags, but each tag maps back to a tag with a different ID with the same name.

The SQL query below reveals that on my system I have 17 tags that have at least one duplicate.

select distinct name from tags where name in (select name from tags group by name having count(*) > 1);"

I can't reproduce it in test, but it's happening in production. It doesn't happen very often, but my database has over 6m tagged objects most of which are visited nightly, and it produced these 16 duplicates tags over the course of about 2 months.

My code won't add a tag to an object if it's already part of the tag_list collection, and the tags associated with an object are fairly stable so I'm guessing it happens on object creation?