Active Admin - Cancan is released as a Ruby Gem. The gem is to be installed within a Ruby on Rails 3 application. To install, simply add the following to your Gemfile:
You just have two things todo
User permissions are defined in an Ability class. CanCan includes a Rails 3 generator for creating this class.
rails g cancan:ability
See CanCan page [github.com/ryanb/cancan/wiki/defining-abilities] for details.
If the user authorization fails, a CanCan::AccessDenied exception will be raised. You can catch this and modify its behavior in the ApplicationController.
class ApplicationController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| redirect_to root_url, :alert => exception.message end def current_ability @current_ability ||= Ability.new(current_admin_user) end end
See CanCan page [github.com/ryanb/cancan/wiki/exception-handling] for more information.
I have just made the integration between the two gems, the two steps above are the only ones todo to get roles working with ActiveAdmin.
Copyright © 2012 Laurent Cobos, 11Factory. See LICENSE for details.