Just a note for those who find it now ...
You can enable any non-recoverable controller, abstract classes and methods.
Example:
/app/models/role_ability.rb
class RoleAbility def initialize(user) user ||= User.new if user.role == 'Admin' can :manage, Post
: do_this and: on_this are completely arbitrary, but they must match authorization! params in the controller, for example ...
class Controller < ApplicationController def some_abstract_method
Just remember that, most likely, you probably already have permission for the resource happening inside the ApplicationController, maybe this
class ApplicationController authorize_resource || authorize! :admin, Object || load_and_authorize_resource etc end
so remember skip_authorize_resource in your immunity / abstract controller
class AbstractController < ApplicationController skip_authorize_resource def some_abstract_method authorize! :do_this, :on_this end end
Now the administrator can: do_this ,: on_this and will resolve nicely. You probably want to call this ability more semantically, just want to emphasize randomness.
All this uses Cancan 1.5, have not tried anything before.
From https://github.com/ryanb/cancan/wiki/Non-RESTful-Controllers