AnApprentice
AnApprentice

Reputation: 111070

Rails 3 - How to Link to a User given a user_id

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?

Upvotes: 1

Views: 233

Answers (1)

Mitch Dempsey
Mitch Dempsey

Reputation: 39939

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

Should do exactly what you want.

Upvotes: 5

Related Questions