Skip to content
This repository

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.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 init.rb
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.