简体   繁体   English

如何根据登录用户在ROR中的角色限制控制器访问

[英]How to restrict a controller access based on a logged in user's role in ROR

Guys I have 4 tables in my DB as follows 伙计我的数据库中有4个表如下

  • Functions {id, name 函数 {id,name
  • Admin_Users {Id, Email, Password, role_id} Admin_Users {Id,Email,Password,role_id}
  • Roles {id, name} 角色 {id,name}
  • Role_Functions {id, role_id, function_id} Role_Functions {id,role_id,function_id}

I'm using RoR as web development environment. 我正在使用RoR作为Web开发环境。

Here, 这里,

I want to restrict a controller access based on a logged in user's role (role-base-authorization), How I do this? 我想根据登录用户的角色(角色基授权)限制控制器访问,我是怎么做到的? does it requires a new table? 它需要一张新桌子吗?

You can use cancan gem. 你可以使用cancan gem。 It's a cool gem. 这是一个很酷的宝石。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM