views:

28

answers:

2

At the moment, I have this line in routes.rb

map.resources :usernotes

so my paths are /usernotes/new etc

But I realise now I want them to be like /notes/new

Is there a way to change the line in routes.rb to do this?

+1  A: 

Yep, it's super-easy:

map.resources :usernotes, :as => 'notes'

See section 3.7.4 here:

http://guides.rubyonrails.org/v2.3.8/routing.html#controller-namespaces-and-routing (for Rails 2.3.x)

or here for Rails 3: http://guides.rubyonrails.org/routing.html#naming-routes

tfe
I added the Rails version to clarify the answer. Please note that in Rails 3 the route is not called on `map.`
Simone Carletti
A: 

This will give you /notes and /notes/new etc

resources :notes, :controller=>"UserNotes"

You'll use new_note_path etc

Jesse Wolgamott