mbleigh/acts-as-taggable-on — Issue #230: tagged_with might not work if tags have Unicode chars in them
Author: SkyWriter
Created: 2012-02-11 20:06:26+00:00
State: open

The following code will not work:

Theme.tagged_with(['вася', 'федя', 'коля'], :match_all => true)

To build an SQL query it generates table alias names out of tag.safe_name method, which is essentially tag.name with all non-latin chars stripped out. In case when tag is completely non-latin it ends up being an empty string, so safe_name is equal for all the tags in a search. This leads to generating the same table aliases for all the tags and generating an SQL error.

The following monkey patch fixed the issue for me:

module ActsAsTaggableOn

class Tag
def safe_name
id.to_s
end
end

end

If safe_name isn't used anywhere else besides the tagged_with aliasing facility, I'd rather suggest abandoning it and made the aliases be generated based just on tag.id values. IMHO.