Rails 3 授权
我正在尝试弄清楚如何在 Rails 3 应用程序上执行授权。我使用的是 CanCan,但我需要比一个用户角色更复杂一点。
我的应用程序有一个用户模型、项目模型和项目成员模型。这些模型之间存在“Has Many Through”关系设置。以下是当前架构...
用户
- 名字
- 姓氏
- 电子邮件
项目
- 姓名
- 活跃的
项目成员
- 用户 ID
- 项目 ID
- 角色
当用户登录站点时,系统会提示他们从选择菜单中选择一个项目。选择菜单中的选项是从创建的
current_users.departments.where(:active =>正确)
在他们点击提交后,将为 session[:department_id] 设置会话变量。我需要找到一种方法来提取用户和项目的角色 ID,并根据该角色锁定某些内容。
谢谢, 凯尔
I am trying to figure out how I can perform authorization on my Rails 3 application. I was using CanCan, but I needed to get a little more complex than one user role.
My application has a User Model, Project Model and a Project Members Model. There is a Has Many Through relationship setup between those models. Below is the current schema....
Users
- First Name
- Last Name
- Email
Projects
- Name
- active
Project Members
- user_id
- project_id
- role
When a user logs into the site they are prompted to select a project from a select menu. The options in the select menu are created from
current_users.departments.where(:active
=> true)
After they hit submit a session variable is set for session[:department_id]. What I need to find is a way to pull the role id for the user and project and lock down certain things based on the that role.
Thanks,
Kyle
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够通过 CanCan 并在 Ryan B. 的帮助下解决这个问题。
I was able to take care of this with CanCan and with the help of Ryan B.