Rails Devise 用户帮助
在设计中,我将如何(我不知道如何表达它)返回用户。 我可以 user_signed_in 吗?但用户呢? 我想检查显示 @user 是否与当前登录的用户相同。
In devise how would I, I am not sure how to phrase it, return a user.
I am able to user_signed_in? but what about user.
I want to check in show if @user is the same one as the user that is currently signed in.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Devise 具有诸如
current_user
之类的方法,它返回已登录的“用户”。此外,根据您的“用户”模型,辅助方法将进行相应调整。因此,如果您的设备模型有一个
Admin
类,则可以使用current_admin
等内容。Devise has methods like
current_user
which returns the "user" that is logged in.Also, depending on your "User" model the helper methods will be adjust accordingly. So if you have an
Admin
class that is your devise model, you can use something likecurrent_admin
, and so on.Devise 有一个可用的
current_user
帮助程序。Devise has a
current_user
helper that's available.你可以这样做:
但也许你只是想这样做?
You could do this:
But maybe you just want to do this?