通过使用Rails 3.添加多个角色设计? [英] Using Devise with Rails 3. Adding multiple roles?

查看:122
本文介绍了通过使用Rails 3.添加多个角色设计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用的身份验证色器件的宝石在Rails 3应用程序。我们有多个角色,并从色器件待机点,角色将在确认后,激活方面有所不同,记得我的功能。

We are using the devise gem for authentication in a Rails 3 application. We have multiple roles and from the devise stand-point, the roles will differ in terms of confirmation, activation and remember me functionality.

的色器件文档已经被定义两个范围的例子。一个是用户本身,另一种是管理角色。

The devise documentation has examples of two scopes being defined. One is the User itself and the other one is the admin role.

我能有这样的事情?我将创建一个用户模型。然后,我将创建3个角色:

Can I have something like this? I would create a User model. And then I would create 3 roles:


  • 基于role1

  • 基于role2

  • 管理

设计是否支持这种?有没有人尝试过​​这一点?

Does devise support this? Has anybody tried this out?

推荐答案

康康舞是红宝石的角色远的最佳解决方案,我建议你检查出<一个href=\"http://www.tonyamoyal.com/2010/07/28/rails-authentication-with-devise-and-cancan-customizing-devise-controllers/\">Tony's设计/惨惨的使用,以创建一个角色为基础的系统。我花了一点点得到究竟是如何做出来的,但现在它可以创造奇迹适合我。

CanCan is by far your best solution for roles with ruby, I'd suggest checking out Tony's Usage of Devise/CanCan to create a roles based system. It took me a little bit to get exactly how to work it out, but now it works wonders for me.

这篇关于通过使用Rails 3.添加多个角色设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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