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?
A:
There is quite a bit of documentation on the README: http://github.com/be9/acl9 Which part don't you understand?
Ryan Bigg
2009-10-17 06:44:53
I dont see on there how you actually setup different role types..
Kevin Compton
2009-10-18 19:27:26
Ryan Bigg
2009-10-19 04:47:20
A:
Their readme is in fact really good.
I just set it up and these are the steps:
- Create a model class called Role
- Create a migration for the roles table (see readme http://github.com/be9/acl9)
- 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)
- Create a roles_users association table (for the exact migration, again, check out the readme)
- That's it. You done.
You can now assign roles to your user by current_user.has_role! :admin
You can check if a user has a certain role by calling e.g. current_user.has_role? :admin
There are lots of examples in the readme.
StefanS
2009-10-28 12:47:39