具有角色的Rails 4认证模型 [英] Rails 4 Authentication model with roles

查看:84
本文介绍了具有角色的Rails 4认证模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Rails领域的初学者,希望我能在这里找到答案。
我正在从事的项目必须具有简单角色用户和管理员角色的用户授权。拥有管理员权限,我希望能够为简单用户重置密码或为他们添加角色。

I am beginner in Rails world, so hoping I will be able to find an answer here. The project that I am working on, has to have User Authorization with roles, for simple users and for admins. With admin privileges I want to be able reset password for simple users or to add roles for them.

我试图将Devise与cancancan gems结合使用,但不幸的是,使其工作,我不确定这是否可能。所以我的问题是,您建议您推荐哪种宝石具有这种行为。还是从头开始更简单?

I was trying to apply Devise with cancancan gems, but unfortunately, couldn't make it work and I am not sure if that is even possible. So my question is which gems would you recommend to have such behavior. Or it's simpler to start from scratch?

感谢您的回答。

推荐答案

听起来您会从Rolify Gem中受益: https://github.com/RolifyCommunity/rolify 。我很确定CanCan用于基于角色的访问控制。我猜您已经看过这个RailsCast: http://railscasts.com/episodes/192 -cancan授权,但似乎您缺少的是Rolify。这是一颗很棒的宝石,而且非常易于使用。

It sounds like you would benefit from the Rolify Gem: https://github.com/RolifyCommunity/rolify. I'm pretty sure CanCan is for access control based on roles. I'm guessing you have seen this RailsCast: http://railscasts.com/episodes/192-authorization-with-cancan but it seems like the piece you are missing is Rolify. It's a great gem and extremely easy to use.

这篇关于具有角色的Rails 4认证模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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