Routes: Root as Users#Show

Hi,
I’d like to define the root path of my site as the Users#Show action,
therefore whenever someone goes to http://www.example.com they will see
their own profile page.
At the moment I have done this by having the following in my routes.rb
file:

Home Page

map.root :controller => ‘users’, :action => ‘show’

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

This works with respect to showing each users profile page on the route
page. However, if tries to go to http://www.example.com/users/anything
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:
http://www.example.com/users/anything_other_than_their_id

What is the correct way to do this?
Thanks

In the controller, couldn’t you look for/at params[:id] to see if the
request was for a user other than themselves?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs