Excerpts from John Merlino's message of Wed Mar 30 08:45:50 -0700 2011:
So I try to implement:
#routes
resources :core do
collection do
get 'coreim'
get 'corer'
end
end
With that routes file:
$ rake routes
coreim_core_index GET /core/coreim(.:format) {:action=>"coreim", :controller=>"core"}
core_index GET /core(.:format) {:action=>"index", :controller=>"core"}
POST /core(.:format) {:action=>"create", :controller=>"core"}
new_core GET /core/new(.:format) {:action=>"new", :controller=>"core"}
edit_core GET /core/:id/edit(.:format) {:action=>"edit", :controller=>"core"}
core GET /core/:id(.:format) {:action=>"show", :controller=>"core"}
PUT /core/:id(.:format) {:action=>"update", :controller=>"core"}
DELETE /core/:id(.:format) {:action=>"destroy", :controller=>"core"}
So you would have +coreim_core_index_path+, for example.
This rather surprised me, since I had the same expectations as you. Further
investigation suggestions inflections are to blame.
# config/routes.rb
# Note that we changed the resource to a pluralized form: "cores" instead of "core".
resources :cores do
collection do
get 'coreim'
get 'corer'
end
end
$rake routes
coreim_cores GET /cores/coreim(.:format) {:action=>"coreim", :controller=>"cores"}
cores GET /cores(.:format) {:action=>"index", :controller=>"cores"}
POST /cores(.:format) {:action=>"create", :controller=>"cores"}
new_core GET /cores/new(.:format) {:action=>"new", :controller=>"cores"}
edit_core GET /cores/:id/edit(.:format) {:action=>"edit", :controller=>"cores"}
core GET /cores/:id(.:format) {:action=>"show", :controller=>"cores"}
PUT /cores/:id(.:format) {:action=>"update", :controller=>"cores"}
DELETE /cores/:id(.:format) {:action=>"destroy", :controller=>"cores"}
For the record, if rake routes gives you the name coreim_core_index, then the named route will be coreim_core_index_path or coreim_core_index_url… not just coreim_core_index by itself. If you’re changing the route names, that may not matter.