How can I map the url /users/:id to /dashboard?
Thanks
Where is the id
parameter with URL /dashboard
? Or is this about the "current" user?
If these pages are about different users, one from parameter, the other from session. Then you actually need different controllers for these 2 URLs.
Here is how I would do it:
routes.rb
match "dashboard" => 'users#show', :defaults => { :id => -1 }
UsersController.rb
def show
@user = User.find(params[:id] == -1 ? current_user_id : params[:id])
...
I let you do the implementation of current_user_id
:-)
match "users/:id" => "YourDashboardController#dashboard"
did you try something like that:
match "/dashboard", :to => "users#show", :as => "dashboard"
and after login redirect to dashboard_path