Class: Role::ActionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/lesli_shield/role/actions_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/lesli_shield/role/actions_controller.rb', line 26

def destroy
    if @role_action.result.delete
        @role_actions = RoleActionService.new(current_user, query).index(@role.id)
        respond_with_lesli(
            :turbo => [
                stream_notification_warning("Role privileges removed successfully!"),
                turbo_stream.replace('shield-role-actions-form', partial: 'lesli_shield/role/actions/form')
            ]
        )
    else 
        respond_with_lesli(
            :turbo => stream_notification_danger(@role_action.errors_as_sentence)
        )
    end
end

#indexObject



6
7
8
# File 'app/controllers/lesli_shield/role/actions_controller.rb', line 6

def index 
    @role_actions = RoleActionService.new(current_user, query).index(@role.id)
end

#updateObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/lesli_shield/role/actions_controller.rb', line 10

def update
    if @role_action.result.recover
        @role_actions = RoleActionService.new(current_user, query).index(@role.id)
        respond_with_lesli(
            :turbo => [
                stream_notification_success("Role privileges added successfully!"),
                turbo_stream.replace('shield-role-actions-form', partial: 'lesli_shield/role/actions/form')
            ]
        )
    else 
        respond_with_lesli(
            :turbo => stream_notification_danger(@role_action.errors_as_sentence)
        )
    end
end