Class: LesliShield::InvitesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lesli_shield/invites_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /invites



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/lesli_shield/invites_controller.rb', line 24

def create
    @invite = current_user..shield.invites.new(invite_params)
    @invite.user = current_user
    if @invite.save

        log(
            subject: @invite,
            operation: 'invite.created',
            description: "Invitation created successfully created for: #{@invite.email}"
        )
        
        success("Invite was successfully created.")
        respond_with_lesli(
            turbo: stream_redirection(invite_path(@invite))
        ) 
    else
        respond_with_lesli(
            turbo: stream_notification_danger(@invite.errors.full_messages.to_sentence)
        ) 
    end
end

#destroyObject

DELETE /invites/1



64
65
66
67
# File 'app/controllers/lesli_shield/invites_controller.rb', line 64

def destroy
@invite.destroy!
redirect_to invites_path, notice: "Invite was successfully destroyed.", status: :see_other
end

#editObject

GET /invites/1/edit



20
21
# File 'app/controllers/lesli_shield/invites_controller.rb', line 20

def edit
end

#indexObject

GET /invites



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

def index
    @invites = respond_with_pagination(LesliShield::InviteService.new(current_user, query).index(params))
end

#newObject

GET /invites/new



15
16
17
# File 'app/controllers/lesli_shield/invites_controller.rb', line 15

def new
    @invite = Invite.new
end

#showObject

GET /invites/1



11
12
# File 'app/controllers/lesli_shield/invites_controller.rb', line 11

def show
end

#updateObject

PATCH/PUT /invites/1



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/lesli_shield/invites_controller.rb', line 47

def update
    if @invite.update(invite_params)
        log(
            subject: @invite,
            description: "Invitation updated successfully"
        )
        respond_with_lesli(
            :turbo => stream_notification_success("Invite was successfully updated.")
        ) 
    else
        respond_with_lesli(
            :turbo => stream_notification_danger(@invite.errors.full_messages.to_sentence)
        ) 
    end
end