Aliases for routes

Posted . Visible to the public.

The following initializer provides an :alias => "my_route_name" option to restful routes in your route.rb. This simply makes the same route also available under a different ..._path / ..._url helpers.

For example,

map.resources :notes, :alias => :snippets

Gives you

notes_path, notes_url, new_note_path... #as always
snippets_path, snippets_url, new_snippet_path... #from the alias

Put this into an initializer:

Tobias Kraze
Last edit
Attachments
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to makandra dev (2010-11-11 10:02)