forked from ryanb/cancan
-
Notifications
You must be signed in to change notification settings - Fork 0
Changing Defaults
sunzhigang edited this page Jul 17, 2012
·
3 revisions
CanCan makes two assumptions about your application.
- You have an
Ability
class which defines the permissions. - You have a
current_user
method in the controller which returns the current user model.
You can override both of these by defining the current_ability
method in your ApplicationController
. The current method looks like this.
def current_ability
@current_ability ||= Ability.new(current_user)
end
The Ability
class and current_user
method can easily be changed to something else.
# in ApplicationController
def current_ability
@current_ability ||= AccountAbility.new(current_account)
end
That's it! See Accessing Request Data for a more complex example of what you can do here.