Forum: Ruby on Rails Routes: Root as Users#Show

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Tim C. (Guest)
on 2008-11-04 13:52
I'd like to define the root path of my site as the Users#Show action,
therefore whenever someone goes to they will see
their own profile page.
At the moment I have done this by having the following in my routes.rb
  # Home Page
  map.root :controller => 'users', :action => 'show'

The Users controller then looks like:
  def show
    @user = current_user

This works with respect to showing each users profile page on the route
page.  However, if tries to go to
they still see their profile page because I am setting @user to
current_user no matter what the request.
I need to return 404 pages when users go to:

What is the correct way to do this?
Ar C. (Guest)
on 2008-11-04 22:26
In the controller, couldn't you look for/at params[:id] to see if the
request was for a user other than themselves?
This topic is locked and can not be replied to.