Skip to content

Instantly share code, notes, and snippets.

@hrp
Last active January 3, 2016 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrp/8405566 to your computer and use it in GitHub Desktop.
Save hrp/8405566 to your computer and use it in GitHub Desktop.
acts-as-taggable-on speed hack
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