# "me" route

**URL:** <https://www.ruby-forum.com/t/me-route/172217>\
**Category:** Rails\
**Created:** [July 16, 2009, 9:52pm UTC](https://www.ruby-forum.com/t/me-route/172217 "2009-07-16T21:52:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wouter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e99b99/32.png) [@wouter](https://www.ruby-forum.com/u/wouter)\
**Post date:** [July 16, 2009, 9:52pm UTC](https://www.ruby-forum.com/t/me-route/172217/1 "2009-07-16T21:52:06Z")

</div>

Hey,

I have a social network web app with ruby on rails and users can see  
their profile like this: /profiles/2-admin  
Now i want to make an alias or something with the route “/me” so it  
would show the same as profiles/2-admin

so when i go to this: [http://localhost:3000/me](http://localhost:3000/me) it shows me the same as  
[http://localhost:3000/profiles/2-admin](http://localhost:3000/profiles/2-admin)  
so the “me” would show the info from the currently logged in user!

Ho can i do that?

I have tried several things, but nothing succeeded…

Thank you,

Wouter

---

<div class="post-metadata">

**Author:** ![wouter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e99b99/32.png) [@wouter](https://www.ruby-forum.com/u/wouter)\
**Post date:** [July 16, 2009, 10:28pm UTC](https://www.ruby-forum.com/t/me-route/172217/2 "2009-07-16T22:28:54Z")

</div>

Wouter wrote:

> Ho can i do that?
> 
> I have tried several things, but nothing succeeded…

If you already have an action that lets a user see their profile, then  
you could do something like this:

map.connect ‘/me’, :controller =\> ‘profiles’, :action =\>  
‘user\_profile\_action’

Change “user\_profile\_action” to whatever the action is called. Whoever  
follows the /me route should be shown the page with their profile on it.

If you don’t already have such an action, I think creating one would be  
the best way.

HTH

Matt

---

<div class="post-metadata">

**Author:** ![wouter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e99b99/32.png) [@wouter](https://www.ruby-forum.com/u/wouter)\
**Post date:** [July 16, 2009, 10:47pm UTC](https://www.ruby-forum.com/t/me-route/172217/3 "2009-07-16T22:47:02Z")

</div>

Hey,

Thank you for your answer!

When i try this i got this error message

Couldn’t find Profile without an ID

How to solve this?

On Jul 16, 10:27 pm, Matt H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![wouter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e99b99/32.png) [@wouter](https://www.ruby-forum.com/u/wouter)\
**Post date:** [July 16, 2009, 10:50pm UTC](https://www.ruby-forum.com/t/me-route/172217/4 "2009-07-16T22:50:33Z")

</div>

And why cant i do [http://localhost:3000/me.xml](http://localhost:3000/me.xml) (No route matches “/  
me.xml”)

---

<div class="post-metadata">

**Author:** ![wouter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e99b99/32.png) [@wouter](https://www.ruby-forum.com/u/wouter)\
**Post date:** [July 16, 2009, 11:13pm UTC](https://www.ruby-forum.com/t/me-route/172217/5 "2009-07-16T23:13:21Z")

</div>

worked for me like in this thread

[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/5dc070d84feb9d7f](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/5dc070d84feb9d7f)

THANX for the help

---

<div class="post-metadata">

**Author:** ![wouter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e99b99/32.png) [@wouter](https://www.ruby-forum.com/u/wouter)\
**Post date:** [July 16, 2009, 11:00pm UTC](https://www.ruby-forum.com/t/me-route/172217/6 "2009-07-16T23:00:29Z")

</div>

Ok it works now  
this is my action

def show\_me  
@user = Profile.find(@p)  
respond\_to do |wants|  
wants.html {redirect\_to profile\_path(@p)}  
wants.xml {render :xml =\> @user.to\_xml }  
end  
end

and this my route

map.connect ‘/me’, :controller =\> ‘profiles’, :action=\> ‘show\_me’  
but when i try to access /me.xml i get No route matches “/me.xml”

Me.xml is the same as /profiles/2-admin.xml (xml file from profile).

How can i do this?
