This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
README.markdown | Wed Feb 11 05:29:54 -0800 2009 | |
| |
init.rb | Wed Feb 11 02:56:20 -0800 2009 | |
| |
install.rb | Wed Feb 11 02:56:20 -0800 2009 | |
| |
lib/ | Wed Feb 11 02:56:20 -0800 2009 | |
| |
tasks/ | Wed Feb 11 02:56:20 -0800 2009 | |
| |
test/ | Wed Feb 11 02:56:20 -0800 2009 |
README.markdown
PermalinkSlugs
A Rails plugin that adds a permalink method to the models it's applied to. The permalink returned can be defined by the user and doesn't use the id to make it unique. instead it does validate the slug for the model for uniqueness when you create it.
This is my first Rails plugin, please feel free to contact me for enhancement suggestions.
Prerequisites
- You need the to_slug plugin. script/plugin install git://github.com/ludo/to_slug.git
- All models with a permalink need a slug attribute.
- If you want to have nice permalinks for nested pages i recommend awesome_nested_set. script/plugin install git://github.com/collectiveidea/awesome_nested_set.git
Usage
In your model:
permalink_slugs :default => :name, :slug => :slug, :scope => nil, :parent => nil
- :default is the name the slug is being generated from if no slug given. default is :name
- :slug is the name of the field where the slug is stored in the model. default is :slug
- :scope if you want to validate the uniqueness of the slug depending on another field. use it just like with validates_uniqueness_of. no default.
- :parent if you use awesome_nested_set set this to :parent_id. no default.
Get a permalink:
model.permalink
# => "/slug_value"
For nested pages:
model.permalink
# => "/mainpage/subpage"
Todos
Write Tests
There's a issue with awesome_nested_set where slugs are not validated correctly after create. update works fine.
Copyright (c) 2008 Gerold Böhler, released under the MIT license







