Skip to content

Instantly share code, notes, and snippets.

@diegorv
Created August 17, 2010 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegorv/531743 to your computer and use it in GitHub Desktop.
Save diegorv/531743 to your computer and use it in GitHub Desktop.
class RoleSets
role :admin do
can :manage, :all
end
role :diretoria do
can [:read, :edit], [Post]
end
role :maluco do
can [:update], [Post]
end
end
# =========================================================================================================
class Ability < RoleSets
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.role? :admin
role_admin
else
#can :read, :all
if user.role?(:diretoria)
role_diretoria
elsif user.role?(:maluco)
role_diretoria
role_maluco
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment