Rails,如何将表单发布到 Devise?
我想允许我的应用程序的管理员以任何用户身份登录。我在设计维基上找到了以下内容:
class AdminController < ApplicationController
# Sign in as another user if you are an admin
def become
return unless current_user.is_an_admin?
sign_in(:user, User.find(params[:id]))
redirect_to root_path
end
end
在视图中,如何构建一个表单来发布到此?
谢谢
I want to allow an admin on my app to sign in as any user. I found the following on the devise wiki:
class AdminController < ApplicationController
# Sign in as another user if you are an admin
def become
return unless current_user.is_an_admin?
sign_in(:user, User.find(params[:id]))
redirect_to root_path
end
end
In the view, how do you build a form to post to this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您甚至不需要构建表单,只需允许管理员访问以下网址:
example.com/admin/become?id
=25,其中 25 是您想要登录的 ID。
因此,使用这种方法,您只需创建一个链接供管理员单击即可。
You wouldn't even need to build a form, you could simply allow the admin to go to the following url:
example.com/admin/become?id=25
where 25 is the id you want to log into as.
So with this method, you would just create a link for an admin to click on.