在 Devise on Rails beta 3 中创建管理员用户 [英] Creating an admin user in Devise on Rails beta 3

查看:23
本文介绍了在 Devise on Rails beta 3 中创建管理员用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,当有人用我遗漏的简单事情来回答这个问题时,我可能会感到很愚蠢,但是......这里是:

Ok, I'm probably going to feel quite dumb when someone answers this one with a simple thing that I'm missing but... here goes:

我在 rails 3 beta 上有一个全新的应用程序,我正在使用 devise 进行身份验证.我已经运行了所有评论,目前一切正常.我创建了一个用户角色和一个管理员角色(按照以下说明:https://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-Role) 并且我已将自己注册为第一个用户,但我该怎么做注册或创建管理员角色用户?设计人员的指示将管理员角色设置为不可注册,但如果您无法注册,我不确定您应该如何创建管理员?!

I've got a brand new app on rails 3 beta and I'm using devise for the authentication. I've run all the comments and everything is working perfectly at the moment. I've created a user role and an admin role (following these instructions: https://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-Role) and I've registered myself as the first user but how to do I register or create an admin role user? The directions from the devise guys setup the admin role to not be registerable but I'm unsure how you're supposed to create the admin if you can't register?!

任何帮助将不胜感激!谢谢!

Any help would be appreciated! Thanks!

推荐答案

是的.我觉得很蠢.

如果其他人也有类似乏味的时刻.只需使用 rails 控制台创建管理员用户:

If anyone else is having a similarly vapid moment. Just use the rails console to create the admin user:

➡ rails c
Loading development environment (Rails 3.0.0.beta3)
irb(main):001:0> admin = Admin.create! do |u|
irb(main):002:1* u.email = 'sample@sample.com'
irb(main):003:1> u.password = 'password'
irb(main):004:1> u.password_confirmation = 'password'
irb(main):005:1> end

那就行了.现在只需访问您的管理员登录路径并登录.

That will do it. Now just visit your admin sign in path and sign in.

这篇关于在 Devise on Rails beta 3 中创建管理员用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆