Class: Radesk::AnswersController

Inherits:
ApplicationController show all
Includes:
ActivitiesHelper
Defined in:
app/controllers/radesk/answers_controller.rb

Instance Method Summary collapse

Methods included from ActivitiesHelper

#add_activity, #destroy_activities

Methods inherited from ApplicationController

#radesk_authorize!, #radesk_authorize_admin!, #radesk_check_access, #radesk_current_user

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/radesk/answers_controller.rb', line 11

def create
  @answer = Answer.new(answer_params)
  @answer.user_id = radesk_current_user.id
  @answer.ticket_id = params[:ticket_id]

  if @answer.save
    UserMailer.new_answer(@answer).deliver_now
    add_activity(@answer, 'create')
    redirect_to @answer.ticket, notice: 'Answer was successfully created.'
  else
    redirect_to :back, notice: @answer.errors.full_messages.first
  end
end

#destroyObject



37
38
39
40
# File 'app/controllers/radesk/answers_controller.rb', line 37

def destroy
  @answer.destroy
  redirect_to @answer.ticket, notice: 'Answer was successfully destroyed.'
end

#editObject



25
26
# File 'app/controllers/radesk/answers_controller.rb', line 25

def edit
end

#updateObject



28
29
30
31
32
33
34
35
# File 'app/controllers/radesk/answers_controller.rb', line 28

def update
  if @answer.update(answer_params)
    add_activity(@answer, 'update')
    redirect_to @answer.ticket, notice: 'Answer was successfully updated.'
  else
    render :edit
  end
end