Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix crashing issues when saving an object with edge rails on ruby 1.9.2

  • Loading branch information...
commit 1d02ee5f62c1c160712f73c759d084db473ea84c 1 parent 9385e17
@tomeric tomeric authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/acts_as_taggable_on/tag.rb
View
10 lib/acts_as_taggable_on/tag.rb
@@ -47,7 +47,10 @@ def self.find_or_create_all_with_like_by_name(*list)
return [] if list.empty?
existing_tags = Tag.named_any(list).all
- new_tag_names = list.reject { |name| existing_tags.any? { |tag| tag.name.mb_chars.downcase == name.mb_chars.downcase } }
+ new_tag_names = list.reject do |name|
+ name = comparable_name(name)
+ existing_tags.any? { |tag| comparable_name(tag.name) == name }
+ end
created_tags = new_tag_names.map { |name| Tag.create(:name => name) }
existing_tags + created_tags
@@ -72,7 +75,10 @@ class << self
def like_operator
using_postgresql? ? 'ILIKE' : 'LIKE'
end
+
+ def comparable_name(str)
+ RUBY_VERSION >= "1.9" ? str.downcase : str.mb_chars.downcase
+ end
end
-
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.