Class: Faalis::Dashboard::GroupsController

Inherits:
Dashboard::ApplicationController
  • Object
show all
Defined in:
app/controllers/faalis/dashboard/groups_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/faalis/dashboard/groups_controller.rb', line 22

def create
  authorize Faalis::Group

  name = group_params[:name]
  @group = Faalis::Group.new(name: name, role: name.underscore)

  @group.permissions = populate_permissions

  respond_to do |f|
    if @group.save
      f.js
      f.html
    else
      f.js { render :errors }
      f.html
    end
  end

end

#editObject


17
18
19
20
# File 'app/controllers/faalis/dashboard/groups_controller.rb', line 17

def edit
  @group = Faalis::Group.find(params[:id])
  authorize @group
end

#indexObject


6
7
8
9
# File 'app/controllers/faalis/dashboard/groups_controller.rb', line 6

def index
  authorize Faalis::Group
  @groups = Faalis::Group.all
end

#newObject


11
12
13
14
# File 'app/controllers/faalis/dashboard/groups_controller.rb', line 11

def new
  authorize Faalis::Group
  @group = Faalis::Group.new
end

#updateObject


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/faalis/dashboard/groups_controller.rb', line 42

def update
  @group = Faalis::Group.find(params[:id])
  authorize @group
  @group.permissions = populate_permissions
  @group.name        = group_params[:name]
  @group.role        = group_params[:name].underscore

  respond_to do |f|
    if @group.save
      f.js
      f.html
    else
      f.js { render :errors }
      f.html
    end
  end
end