Skip to content

Instantly share code, notes, and snippets.

@noahhendrix
Created July 14, 2010 18:04
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 noahhendrix/475776 to your computer and use it in GitHub Desktop.
Save noahhendrix/475776 to your computer and use it in GitHub Desktop.
class Ability
include CanCan::Ability
def initialize(user)
if user.is? :admin
can :read, :all
can :manage, Activity, :user_id => [user.id, *user.asm_ids]
elsif user.is? :supervisor
can :manage, Activity, :user_id => [user.id, *user.asm_ids]
elsif user.is? :ASM
can :manage, Activity, :user_id => user.id
end
can :read, Contact
can :manage, Contact do |contact|
contact && user.contact_ids.include?(contact.id)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment