设计用户个人资料link_to [英] Devise User Profile link_to
本文介绍了设计用户个人资料link_to的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我目前正在尝试找出使用的路径,因此,当用户单击查看个人资料时,链接将是domain.com/USERNAME而不是domain.com/profiles/show
So I am currently trying to figure out what path to use so when the user clicks on 'View Profile' the link will be domain.com/USERNAME instead of domain.com/profiles/show
我当前的链接代码是
<li><%= link_to "View Profile", profiles_show_path %></li>
我的路线。rb设置为
get '/:id' to: 'profiles#show'
推荐答案
您需要在链接中指定用户作为参数:
You need to specify an user as parameter in your link:
<li><%= link_to "View Profile", profile_path(user) %></li>
在您的路线中:
get '/:id', to: 'profiles#show', as: :profile
因此,您将覆盖默认的 profile_path()
。
So you're overriding the default profile_path()
.
这篇关于设计用户个人资料link_to的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文