Created
December 21, 2010 08:08
-
-
Save alg/749649 to your computer and use it in GitHub Desktop.
No underscore/dash escaping in Mongoid
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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
only this version (https://gist.github.com/749649/87ae99a47430846d2854aae63192d4704c423b71) working properly for turkish charset ( Öö Çç Üü Şş Iı İi Ğğ)