Simple_slugs is a project mainly written in Ruby, it's free.
h1. SimpleSlugs
simple_slugs aims to be an as-simple-as-possible implementation of slugging/permalink functionality for ActiveRecord 3, but still be I18n-ready by providing transliteration support.
h2. Usage
simple_slugs adds an act_macro to activate slugging support for an ActiveRecord model:
class Post has_slug end
simple_slugs has the following assumptions/defaults:
You can overwrite these defaults as follows:
class Post has_slug :slug_name => :permalink, # use the permalink column for storing the slug :source => :heading, # use the heading column as a source :on_blank => false, # always update the slug :scope => :blog_id # scope uniqueness of slugs to the current blog_id end
h2. Slugging
simple_slugs performs the following operations on the source value (e.g. post.title):
transliterate! # using the current locale, e.g. German "Ä" => "Ae" spacify! # replace everything except word chars with spaces join_spaces! # replace duplicate spaces with single spaces strip! # strip leading and tailing spaces downcase! # downcase the string dasherize! # replace spaces with dashes