Class: Ability
- Inherits:
-
Object
- Object
- Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/ability.rb
Instance Method Summary collapse
- #default_abilities_for(user) ⇒ Object
-
#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 |
# File 'app/models/ability.rb', line 6 def initialize(user) if user && user.administrator? can :manage, :all elsif Houston.config.defines_abilities? Houston.config.configure_abilities(self, user) else default_abilities_for(user) end end |
Instance Method Details
#default_abilities_for(user) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/ability.rb', line 18 def default_abilities_for(user) # Anyone can see everything can :read, :all if user # If you're logged in, you can update yourself can :update, user if user.developer? or user.tester? # Developers and Testers can see and comment on Testing Reports # They can also edit their own notes can [:create, :read], TestingNote can [:update, :destroy], TestingNote, user_id: user.id end if user.developer? # Developers can manage projects and releases can :manage, Project can :manage, Release can :manage, Sprint end end end |