-
Install the acl_manager gem:
gem install 'acl_manager'
or put it inside your Gemfile:gem 'acl_manager'
-
Add the acl_manager module into devise inside your model:
devise :database_authenticatable, :registerable, ..., :acl_manager
-
Install the migrations. run:
rails g acl_manager MODEL
-
Open up your console and build the acls
AclManager::Acl.build_all!
-
Create your first role. eg: Admin
AclManager::Role.create(name: 'admin', active: true, description: 'gives users admin access')
role = AclManager::Role.first
role.acls << AclManager::Acl.first
user = User.first
user.roles << role
- Add Acl Manager filter to your controllers
class ApplicationController < ActionController::Base
before_filter :authenticate_user!, :authorizate_user!
...
end
= f.collection_check_boxes :role_ids, AclManager::Role.all, :id, :name do |ff|
= f.label
= f.check_box
activerecord.attributes.acl_manager.role.#{role_name}
This project rocks and uses MIT-LICENSE.