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

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

问题描述

好的,当有人用简单的事情回答我的时候,我可能会觉得很愚蠢,但是... ...这里:



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



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

解决方案

Yup。我觉得很笨。



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

 ➡rails c 
加载开发环境(Rails 3.0.0 .beta3)
irb(main):001:0> admin = Admin.create!做| 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>结束

这样做。现在只需访问您的管理员登录路径并登录。


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:

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!

解决方案

Yup. I feel dumb.

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天全站免登陆