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?
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?
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
This will give you /notes
and /notes/new
etc
resources :notes, :controller=>"UserNotes"
You'll use new_note_path etc