Skip to content

Instantly share code, notes, and snippets.

@jonpaul
Created November 15, 2011 21:38
Show Gist options
  • Save jonpaul/1368446 to your computer and use it in GitHub Desktop.
Save jonpaul/1368446 to your computer and use it in GitHub Desktop.
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