Reputation: 1267
Say I have a route users/:id
, where id = 1. Pretty standard, but I would like to change this route to the following:
/account
Where any logged in user, in this case a user with an id = 1, does not see their uid as the segment key, but instead a generic 'account' URI only. How can I achieve this in a rails 3 application?
Upvotes: 0
Views: 146
Reputation: 13925
You can create a route to a standard action which functions as a users own show action. E.g.: you create an action where you get the current user's information and make it shown. The current user can be extracted from the session as usual, so no need for sending out the user id in the url. And you only need a route which redirects /account
to this action.
Upvotes: 1