It's a simple plugin (2 lines of code beside class and modules declarations) which allows routes created via the map.resources mechanism to be customized. Say you have the following map:
map.resources :members
It will generate routes like:
/members
/members/:id
/members/new
No say you want to i18n your app, in french for example, what do you do ? You just can't out of the box. This is where my plugin enters into action, just add a :route_name parameter to the map.resources call and you're set:
map.resources :members, :route_name => 'utilisateurs'
will generate routes like:
/utilisateurs
/utilisateurs/:id
/utilisateurs/new
It shall also work for nested resources, although I did not test that.
The code is actually pretty simple:
module ActionController
module Resources
class Resource
def path
route_name = @options.include?(:route_name) ? @options[:route_name] : @plural
@path ||= "#{path_prefix}/#{route_name}"
end
end
end
end
To install just use script/plugin:
script/plugin install http://tools.assembla.com/svn/riskle/rails/plugins/named_resources
or to install as an svn:external resource:
script/plugin install -x http://tools.assembla.com/svn/riskle/rails/plugins/named_resources