Class: Ability

Inherits:
Object
  • Object
show all
Includes:
CanCan::Ability
Defined in:
app/models/ability.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ 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
# File 'app/models/ability.rb', line 4

def initialize(user)
  if user && user.class.name === 'Users::Sudoer'
    can :access, :ckeditor
    can :access, :rails_admin
    can :dashboard

    can :manage, :all
  end

  if user && user.class.name === 'Users::Admin'
    can :access, :ckeditor
    can :access, :rails_admin
    can :dashboard

    can [:read, :create, :update, :destroy, :export], Catalog
    can [:read, :create, :update, :destroy, :export], Category
    can [:read, :create, :update, :destroy         ], Ckeditor::Picture
    can [:read,                             :export], Contact
    can [:read, :create, :update, :destroy, :export], News
    can [:read, :create, :update, :destroy, :export], Photo
    can [:read, :create, :update, :destroy, :export], Product
    can [:read, :create, :update, :destroy, :export], User
    cannot :manage, Users::Sudoer
  end
end