Thanks for reporting, put a pr-welcome on this, I guess we need to change that find_by_name to do a case insensitive lookup.
Given we have:
The fix would be:
tag = Tag.where('lower(name) = ?', tag_name.downcase).first
TagGroup is missing the index, so we would need to add it and then do the same there.