Created
July 24, 2008 00:57
-
-
Save oliyoung/1976 to your computer and use it in GitHub Desktop.
convert a string into a URL safe slug
This file contains hidden or 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
class String | |
def to_param | |
self.downcase.strip.gsub(/[\/ ]+/, "-").gsub(/[^a-z0-9\-\_]+/i, "").gsub(/\-+/,"-") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment