public
Description: git-svn mirror of acts_as_sluggable rails plugin from http://code.dunae.ca/acts_as_slugable/ - although you should really be using slugify instead
Homepage: http://code.dunae.ca/acts_as_slugable/README
Clone URL: git://github.com/smtlaissezfaire/acts_as_sluggable.git
name age message
file MIT-LICENSE Sat Mar 24 13:21:34 -0700 2007 Initial import git-svn-id: http://code.dunae.c... [alexdunae]
file README Fri Dec 14 15:33:32 -0800 2007 README typo git-svn-id: http://code.dunae.ca/a... [alexdunae]
file TODO Sat Mar 24 17:05:46 -0700 2007 Fixed up unit tests General clean up git-svn-i... [alexdunae]
file init.rb Sat Mar 24 13:21:34 -0700 2007 Initial import git-svn-id: http://code.dunae.c... [alexdunae]
directory lib/ Fri Dec 14 15:28:01 -0800 2007 Removed duplicate call to after_validation :cre... [alexdunae]
file rakefile Sat Mar 24 13:21:34 -0700 2007 Initial import git-svn-id: http://code.dunae.c... [alexdunae]
directory test/ Wed Sep 19 14:46:58 -0700 2007 Updated test/acts_as_slugable_test.rb to reflec... [alexdunae]
README
= Acts as slugable readme

Generates a URL slug based on a specific fields (e.g. title).

A url slug is a string derived from a specific field which can the be used in a URL.  For instance, a page with the 
title <tt>My page</tt> would have a URL slug of <tt>my-page</tt>.

The slug is generated on save and create actions.  If the field has an existing URL slug (like when editing an existing 
record) the URL slug is preserved.

URL slugs are unique within the specified scope (or all records if no scope is defined).  If the slug already exists 
within the scope, <tt>-n</tt> is added (e.g. <tt>my-page-0</tt>, <tt>my-page-1</tt>, etc...


== Installation
<tt>./script/plugin install http://code.dunae.ca/acts_as_slugable</tt>


== Usage examples

In your target table, add a column to hold the URL slug.


=== With scope

  class Page < ActiveRecord::Base
    acts_as_slugable :source_column => :title, :target_column => :url_slug, :scope => :parent
  end

=== Without scope

  class Post < ActiveRecord::Base
    acts_as_slugable :source_column => :title, :target_column => :url_slug
  end

===  A sample link

  link_to @page.title, :action => 'show', :url_slug => @page.url_slug


== Testing

The unit tests for this plugin use an in-memory sqlite3 database (http://www.sqlite.org/).

To execute the unit tests run the default rake task (<tt>rake</tt>). To execute the unit tests but preserve to debug log 
run <tt>rake test</tt>.

== Credits

Created by Alex Dunae (http://dunae.ca/), 2006-07, though it takes a village to raise a plugin:

Thanks to Andrew White (http://pixeltrix.co.uk/) for fixing a conflict with <tt>acts_as_list</tt>.

Thanks to Philip Hallstrom (http://pjkh.com/) for pointing out some redundant code.