public
Description: How I wanted permalinks work ...
Homepage:
Clone URL: git://github.com/fesplugas/simplified_permalink.git
Francesc Esplugas (author)
Mon Apr 13 02:57:45 -0700 2009
commit  0747e41bd03ca5150b27e8fa194cd85b5f22e53d
tree    985286383374b0d62c89c86b286587699cdd2ee1
parent  f54d53f5ab95d35e24b421fc4dcc7ff830aea21f
name age message
file MIT-LICENSE Loading commit data...
file README.rdoc
file Rakefile
file init.rb
directory lib/
directory test/
README.rdoc

Simplified Permalink

I know there are some plugins out there that do the same, but this one fits my needs.

Example

Add to your posts the permalink attribute.

    add_column :posts, :permalink, :null => false
    add_index :posts, :permalink

And use it on your models.

    class Post < ActiveRecord::Base
      permalink :title
      permalink :title, :slug # If you want to use a custom attribute.
    end

So now you can find your posts with:

    class Posts < ApplicationController

      def show
        @post = Post.find_by_permalink_and_status!(params[:id])
      end

    end

About the Author

Francesc Esplugas - francescesplugas.com

Copyright © 2008-2009 Francesc Esplugas Marti, released under the MIT license