# Link\_to \> logged\_in\_user.username

**URL:** <https://www.ruby-forum.com/t/link-to-logged-in-user-username/118713>\
**Category:** Rails\
**Created:** [October 30, 2007, 11:43am UTC](https://www.ruby-forum.com/t/link-to-logged-in-user-username/118713 "2007-10-30T11:43:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [October 30, 2007, 11:43am UTC](https://www.ruby-forum.com/t/link-to-logged-in-user-username/118713/1 "2007-10-30T11:43:02Z")

</div>

Hi there…

A newbie question…

The link below links to the users-page…that works fine…

- \<%= link\_to 'MyLink', user\_path(logged\_in\_user) -%\>

But i don’t want the link ‘Mylink’ but the username instead of. The  
username is stored in logged\_in\_user.username

How can i realize…this…

swoany

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [October 30, 2007, 11:45am UTC](https://www.ruby-forum.com/t/link-to-logged-in-user-username/118713/2 "2007-10-30T11:45:04Z")

</div>

Remco S. wrote:

> - \<%= link\_to 'MyLink', user\_path(logged\_in\_user) -%\>
> 
> But i don’t want the link ‘Mylink’ but the username instead of. The  
> username is stored in logged\_in\_user.username

\<%= link\_to logged\_in\_user.username, user\_path(logged\_id\_user) -%\>

Lutz

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [October 30, 2007, 11:57am UTC](https://www.ruby-forum.com/t/link-to-logged-in-user-username/118713/3 "2007-10-30T11:57:33Z")

</div>

Lutz H. wrote:

> Remco S. wrote:
> 
> > - \<%= link\_to 'MyLink', user\_path(logged\_in\_user) -%\>
> > 
> > But i don’t want the link ‘Mylink’ but the username instead of. The  
> > username is stored in logged\_in\_user.username
> 
> \<%= link\_to logged\_in\_user.username, user\_path(logged\_id\_user) -%\>
> 
> Lutz

Hi Lutz…thanks!!

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [October 30, 2007, 12:08pm UTC](https://www.ruby-forum.com/t/link-to-logged-in-user-username/118713/4 "2007-10-30T12:08:49Z")

</div>

Hi,

Remco S. wrote:

> Lutz H. wrote:
> 
> > \<%= link\_to logged\_in\_user.username, user\_path(logged\_id\_user) -%\>

Take a look at

> **[ActionView::Helpers::UrlHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#M000491)**
>
> Provides a set of methods for making links and getting URLs that depend on the routing subsystem (see ActionDispatch::Routing).

for more details of the link\_to helper.

Lutz
