Skip to content

Instantly share code, notes, and snippets.

@alg
Created December 21, 2010 08:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alg/749649 to your computer and use it in GitHub Desktop.
Save alg/749649 to your computer and use it in GitHub Desktop.
No underscore/dash escaping in Mongoid
# Instead of the standard composition, convert everything
# non-alpha and non-digit to dash and squeeze
class String
def identify
if Mongoid.parameterize_keys
gsub(/[^a-z0-9]+/, ' ').strip.gsub(' ', '-')
else
self
end
end
end
@airy
Copy link

airy commented Jun 3, 2011

only this version (https://gist.github.com/749649/87ae99a47430846d2854aae63192d4704c423b71) working properly for turkish charset ( Öö Çç Üü Şş Iı İi Ğğ)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment