简体   繁体   English

acl9尝试进行设置

[英]acl9 trying to set it up

Anyone have experience with this plugin? 任何人都有使用此插件的经验吗? I have it installed but I have no idea how to implement it. 我已经安装了它,但是我不知道如何实现它。 How do I define the different roles? 如何定义不同的角色?

自述文件中有很多文档: http : //github.com/be9/acl9您不了解哪一部分?

Their readme is in fact really good. 他们的自述文件实际上非常好。

I just set it up and these are the steps: 我只是设置好了,这些是步骤:

  1. Create a model class called Role 创建一个名为Role的模型类
  2. Create a migration for the roles table (see readme http://github.com/be9/acl9 ) 为角色表创建迁移(请参见自述文件http://github.com/be9/acl9
  3. Add acts_as_authorization_subject to your user model (assuming you have something like that already. Check out the authlogic plugin. There's an excellent railscast about authlogic (I think #160) 将acts_as_authorization_subject添加到您的用户模型中(假设您已经拥有类似的东西。查看authlogic插件。关于authlogic的文章非常棒(我认为#160)
  4. Create a roles_users association table (for the exact migration, again, check out the readme) 创建一个role_users关联表(要进行准确的迁移,请再次查看自述文件)
  5. That's it. 而已。 You done. 你做完了

You can now assign roles to your user by current_user.has_role! 您现在可以通过current_user.has_role向您的用户分配角色! :admin :管理员

You can check if a user has a certain role by calling eg current_user.has_role? 您可以通过调用current_user.has_role?检查用户是否具有特定角色。 :admin :管理员

There are lots of examples in the readme. 自述文件中有很多示例。

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

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