Created
July 12, 2011 18:02
-
-
Save dchapman1988/1078555 to your computer and use it in GitHub Desktop.
Lines 9-11 make me happy :-)
This file contains 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) | |
user ||= User.new # guest user (not logged in) | |
if user.admin? | |
can :manage, :all | |
elsif user.manager? | |
can :manage, Client, Client.where(:user_id => user.id) do |client| | |
client.user_id == user.id | |
end | |
else | |
can :read, :all | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment