Skip to content

bhushangahire/simplified_permalink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

How I wanted permalinks work ...

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published