Bounga / Acts_as_nice_url (http://bitbucket.org/Bounga/acts_as_nice_url/)

A Ruby on Rails plugin to generate pretty URLs from models data

 NB: This is not the latest revision. For the latest view, go to tip.

View at rev
Acts_as_nice_url /
filename size last modified message
lib  
tasks  
test  
.hgignore 34 B 16 months ago Gemified plugin
.hgtags 48 B 16 months ago Added tag v1.0.0 for changeset 841329ca5082
LICENSE 1.0 KB 16 months ago Gemified plugin
README 1.4 KB 16 months ago Gemified plugin
Rakefile 2.3 KB 14 months ago Optimized for Rails >= 2.2
init.rb 62 B 14 months ago Optimized for Rails >= 2.2
install.rb 25 B 17 months ago Initial import
uninstall.rb 27 B 17 months ago Initial import

README

--markdown--

NiceUrl

This acts_as extension provides the capabilities for creating a nice url based on an attribute of the current object. You can set / unset the object id in front of the URL and choose the object attribute to use to generate the URL.

Installation

In your Rails app root, use the following command-line :

cd vendor/plugins
hg clone http://bitbucket.org/Bounga/acts_as_nice_url/

or install it system-wide :

$ sudo gem install acts_as_nice_url

and require it in Rails::Initializer (environment.rb) :

config.gem 'acts_as_nice_url'

Example

In your model :

class Player < ActiveRecord::Base
  acts_as_nice_url :id => false, :title => :full_name
end

then in your views :

link_to(:controller => :players, :action => :show, :id => @player)

or

player_path(@player)

Use id only in some case

If you want to use the id only in the generated URL, you have to fill the id parameter with the id only, not the full object :

link_to(:controller => :players, :action => :show, :id => @player.id)

or

player_path(@player.id)

Other

For more information see Project homepage

Problems, comments, and suggestions are welcome on the ticket system

Copyright (c) 2008 Nicolas Cavigneaux, released under the MIT license