public
Description: Add permalink support to Rails apps with this plugin
Clone URL: git://github.com/fnando/has_permalink.git
Search Repo:
fnando (author)
Sat Jul 19 08:06:09 -0700 2008
name age message
folder MIT-LICENSE Sat Jul 19 08:06:09 -0700 2008 first commit [fnando]
folder README Sat Jul 19 08:06:09 -0700 2008 first commit [fnando]
folder init.rb Sat Jul 19 08:06:09 -0700 2008 first commit [fnando]
folder lib/ Sat Jul 19 08:06:09 -0700 2008 first commit [fnando]
folder test/ Sat Jul 19 08:06:09 -0700 2008 first commit [fnando]
README
has_permalink
=============

Instalation
-----------

1) Install the plugin with `script/plugin install git://github.com/fnando/has_permalink.git`
2) Install the unicode gem with `sudo gem install unicode`

Usage
=====
1) Add the method call `has_permalink` to your model. Your model should have a 'permalink' attribute.

class Page < ActiveRecord::Base
  has_permalink :title
end

You can specify the permalink field:

class page < ActiveRecord::Base
  has_permalink :title => :title_permalink
end

If you don't want to use has_permalink, you can call 'some text'.to_permalink string method.

NOTE: Permalinks are not unique. Remember to override to_param method as follow:

def to_param
  "#{id}-#{permalink}"
end

By overriding to_param method you don't have to change a thing on your app routes. ;)

The permalink is created when after_validation callback is evaluated. This plugin also tries
to generate a permalink when before_save callback is evaluated and the instance has no permalink set.

Copyright (c) 2008 Nando Vieira, released under the MIT license