我找到了一个教程https://github.com/danweller18/devise/wiki/Allow-Users-to-View-Profile-and-List-All-Users
但这声称只允许用户查看自己的配置文件。我到底该怎么做(查看别人的个人资料)
发布于 2017-04-20 08:49:45
井,
这是最常见的情况,在你的路线上你需要这样的东西
get user/:user_id/profile然后在你的观点上,你可以做一些类似的事情
if current_user.id == params[:user_id]
# your content when the user is the same
else
# content for others此外,您还可以尝试在控制器上执行此操作,并呈现不同的内容。
发布于 2017-04-20 05:08:10
您可以查看其他人的配置文件,因为在路由中有一个用户的:id。若要链接到用户的配置文件,请使用:
// using user's name as params
<%= link_to user_path(@user.name) %>或
// using user's id as params
<%= link_to user_path(@user) %>https://stackoverflow.com/questions/43509799
复制相似问题