Users can view and edit account information in my app using UsersController
This controller only ever shows information about the current user.
I want to adjust the routes so that:
-
get /accountaccessesUsersController#show, user_id is retrieved from acurrent_uservariable -
get /account/editsimilarly accessesUsersController#edit -
put /account/will hitUsersController#update, again usingcurrent_userinstead of an ID
Basically I want to refer to UsersController as ‘account’ in my URLs and I don’t want to use IDs because I’m always just using the current user. I also don’t want URLs like /users/1 to function at all.
How can I achieve this?
I think that you are talking about singular resources.
http://guides.rubyonrails.org/routing.html#singular-resources
Update
Since you need “/account” instead of “/user”, you should do