Class: Atreides::Ability
- Inherits:
-
Object
- Object
- Atreides::Ability
- Includes:
- Extendable, CanCan::Ability
- Defined in:
- app/models/atreides/ability.rb
Instance Method Summary collapse
-
#initialize(user) ⇒ Ability
constructor
Define abilities for the passed in user here.
Constructor Details
#initialize(user) ⇒ Ability
Define abilities for the passed in user here. For example: doc: github.com/ryanb/cancan/wiki/Defining-Abilities
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/atreides/ability.rb', line 6 def initialize(user) user ||= Atreides::User.new if user.admin? can :manage, :all elsif user.role == :editor can :read, :all can :manage, Atreides::Post can :manage, Atreides::Page elsif user.role == :writer can :read, :all can :create, Atreides::Page can :create, Atreides::Post can :manage, Atreides::Page, :author => user can :manage, Atreides::Post, :author => user end end |