Class: Ability
- Inherits:
-
Object
- Object
- Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/users/ability.rb
Overview
See the wiki for details: github.com/ryanb/cancan/wiki/Defining-Abilities
Instance Method Summary collapse
-
#initialize(user) ⇒ Ability
constructor
A new instance of Ability.
Constructor Details
#initialize(user) ⇒ Ability
Returns a new instance of Ability.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/models/users/ability.rb', line 6 def initialize(user) if user.present? entities = [Account, Campaign, Contact, Lead, Opportunity] can :create, :all can :manage, entities, :access => 'Public' can :manage, entities + [Task], :user_id => user.id entities.each do |klass| = user..where(:asset_type => klass.name) can :manage, klass, :id => .map(&:asset_id) end end end |