Last active
January 3, 2016 03:59
-
-
Save hrp/8405566 to your computer and use it in GitHub Desktop.
acts-as-taggable-on speed hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActsAsTaggableOn | |
mattr_accessor :ignore_case_for_mysql | |
@@ignore_case_for_mysql = false | |
class Tag | |
class << self | |
def named_any_with_ignore_case(list) | |
if ActsAsTaggableOn.ignore_case_for_mysql | |
where(list.map { |tag| sanitize_sql(["name = ?", tag.to_s.mb_chars.downcase]) }.join(" OR ")) | |
else | |
self.named_any_without_ignore_case(list) | |
end | |
end | |
alias_method_chain :named_any, :ignore_case | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment