I am trying to make the user profile a link on my project.
originally, my code would be:
<%= gig.user.profile %>
which would just display the user profile name.
I want to set a link to but all i can get to work is:
<%= link_to "user", gig.user.profile %>
It links correctly to the user profile page but obviously does not display the correct user profile name.
I have also tried:
<%= link_to user.profile_name(id: gig.user.profile_name) %>
but it just throws an error. any ideas?
答案 0 :(得分:0)
假设你看起来像,
<%= link_to gig.user.profile.name, gig.user.profile %>
假设profile
具有name
属性。
答案 1 :(得分:0)
想出来。我的用户类声明我的profile_name实际上只是个人资料。正确的代码如下:
<%= link_to gig.user.profile, gig.user.profile %>