Skip to content

Instantly share code, notes, and snippets.

@oliyoung
Created July 24, 2008 00:57
Show Gist options
  • Save oliyoung/1976 to your computer and use it in GitHub Desktop.
Save oliyoung/1976 to your computer and use it in GitHub Desktop.
convert a string into a URL safe slug
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