views:

20

answers:

1

I'm outputting comments on a /books/1

I have the following:

<%= comment.user.id%>  ---- This gives the correct user_id

What I want to do is create:

<%= link_to comment.user.fname, XXXXXXXXXXXXXX %>

What I don't know what to put for XXXXXXXXXXXXXX that links to /users/1 1 being the id from the comment.user.id

Ideas?

+4  A: 
<%= link_to comment.user.fname, comment.user %>

Should do exactly what you want.

webdestroya
God I love Rails.. I had figured out "User.find(comment.user.id)" but your solution is way better!
AnApprentice
@TheAppren - Happy to help! Thanks for accepting the answer :)
webdestroya