Class: Ability
- Inherits:
-
Object
- Object
- Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/ability.rb
Instance Method Summary collapse
-
#initialize(u) ⇒ Ability
constructor
A new instance of Ability.
Constructor Details
#initialize(u) ⇒ Ability
Returns a new instance of Ability.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/ability.rb', line 4 def initialize(u) if u.is_super_admin? can :manage, :all can :publish, :all can :assign_roles, Tenon::User elsif u.is_admin? can :manage, :all can :publish, :all can :assign_roles, Tenon::User can(:destroy, Tenon::Page) { |page| page.key.blank? } cannot :update, Tenon::User can([:update], Tenon::User) do |user| !user.is_super_admin? end can :create, Tenon::User elsif u.is_contributor? can([:update, :edit], Tenon::User) { |user| user == u } can :read, :all can :create, Tenon::Page can([:update, :destroy, :edit], Tenon::Page) do |item| u.id == item.creator_id end can(:destroy, Tenon::Page) { |page| page.key.blank? } else can :read, :all end end |