Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Rails plugin that adds a to_slug method to String instances. Slugs can be used for URLs, since all 'dangerous' characters have been filtered out.
Ruby
tree: ffbc58ab86
1 comment

Cleaned up a little. Still trying to figure out how I can omit the ne…

…ed for an entire Rails app to spec this plugin. Just requiring active_support didn't do the trick.
latest commit ffbc58ab86
Ludo van den Boom authored

README.markdown

ToSlug

This plugin adds a to_slug method to String instances. With this method you can easily generate a slug from any string. Slugs can be used for URLs, since all 'dangerous' characters have been filtered out.

Examples

"Hello World".to_slug
# => "hello-world"

"The World is Beautiful!".to_slug 
# => "the-world-is-beautiful"

It handles unicode characters too:

"aëòúi".to_slug 
# => "aeoui"

And underscores are left intact:

"Please leave my_underscores_intact".to_slug
# => "please-leave-my_underscores_intact"

See the specs for more (complex) examples.

Installation

Using Rails plugin installer script:

script/plugin install git://github.com/ludo/to_slug.git

Or as a submodule in a Git repository:

git submodule add git://github.com/ludo/to_slug.git vendor/plugins/to_slug

Copyright (c) 2008 Cubicphuse, released under the MIT license

Something went wrong with that request. Please try again.