Slugify String

Convert a string to a URL-friendly slug.

Code

General
str.downcase.gsub(/[^a-z0-9]+/, '-').gsub(/^-|-$/, '')

Parameters

The string to slugify

Server

More Ruby Snippets