Created
November 15, 2011 21:38
-
-
Save jonpaul/1368446 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ability | |
include CanCan::Ability | |
def initialize user, options = {} | |
user ||= User.new | |
role_call = ["admin", "boss", "exporter", "member"] | |
role_call.each do |r| | |
if user.roles.has?(r) | |
"#{r}" + _rules | |
else | |
guest_rules | |
end | |
end | |
end | |
def admin_rules | |
can :manage, :all | |
end | |
def boss_rules | |
can :manage, :all | |
end | |
def exporter_rules | |
end | |
def member_rules | |
end | |
def guest_rules | |
can :read, PagesController | |
can :create, Organization | |
can :create, User | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment