Skip to content

Instantly share code, notes, and snippets.

@jamesbrooks
Created September 1, 2008 03:08
Show Gist options
  • Save jamesbrooks/8260 to your computer and use it in GitHub Desktop.
Save jamesbrooks/8260 to your computer and use it in GitHub Desktop.
class String
def slugify
returning self.downcase.gsub(/'/, '').gsub(/\//, ' ').gsub(/&/, ' and ').gsub(/[^a-z0-9]+/, '-') do |slug|
slug.chop! if slug.last == '-'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment