I’m reading these two pages
The Rails Guides page shows
map.resources :photos, :new => { :upload => :post }
And its corresponding URL
/photos/upload
This looks wonderful.
My routes.rb shows this
map.resources :users, :new => { :signup => :get, :register => :post }
When I do: [~/my_app]$ rake routes
I see the two new routes added
signup_new_user GET /users/new/signup(.:format)
register_new_user POST /users/new/register(.:format)
Note the inclusion of /new! I don’t want that. I just want /users/signup and /users/register (as described in the Rails Routing Guide).
Any help?
When you expose a controller as a resource, following actions are automatically added:
These actions can be categorized in to two groups:
:memberactionsThe URL for the member action has the id of the target resource. E.g:
You can think of
:memberaction as an instance method on a class. It always applies on an existing resource.Default member actions:
show,edit,update,destroy:collectionactionsThe URL for the
:collectionaction does not contain the id of the target resource. E.g:You can think of
:collectionaction as a static method on a class.Default collection actions:
index,new,createIn your case you need two new actions for registration. These actions belong to :collection type( as you do not have the id of the user while submitting these actions). Your route can be as follows:
The URL for the actions are as follows:
If you want to remove a standard action generated by Rails use :except/:only options:
Edit 1
I usually treat the
confirmationaction as a:memberaction. In this caseparams[id]will contain the confirmation code.Route configuration:
URL
Controller