Skip to content

Instantly share code, notes, and snippets.

@dchapman1988
Created July 12, 2011 18:02
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 dchapman1988/1078555 to your computer and use it in GitHub Desktop.
Save dchapman1988/1078555 to your computer and use it in GitHub Desktop.
Lines 9-11 make me happy :-)
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