Class: ThinkFeelDoEngine::Coach::PhqAssessmentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/think_feel_do_engine/coach/phq_assessments_controller.rb

Overview

Allows a Coach to manage Participants’ phq assessments.

Constant Summary

Constants inherited from ApplicationController

ApplicationController::CSRF_COOKIE_NAME, ApplicationController::CSRF_HEADER_NAME, ApplicationController::INACTIVE_MESSAGE, ApplicationController::ROOT_URI

Instance Method Summary collapse

Methods inherited from ApplicationController

#access_denied_resource_path, #after_sign_in_path_for, #after_sign_out_path_for, #raise_not_found!, #render_not_found

Instance Method Details

#createObject

POST /coach/phq_assessments



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/think_feel_do_engine/coach/phq_assessments_controller.rb', line 30

def create
  @phq_assessment = @participant
                    .phq_assessments
                    .build(coach_phq_assessment_params)
  authorize! :create, @phq_assessment

  if @phq_assessment.save
    redirect_to(
      coach_phq_assessments_url(participant_id: @participant.id),
      notice: "Phq assessment was successfully created."
    )
  else
    render :new
  end
end

#destroyObject

DELETE /coach/phq_assessments/1



60
61
62
63
64
65
66
67
# File 'app/controllers/think_feel_do_engine/coach/phq_assessments_controller.rb', line 60

def destroy
  authorize! :destroy, @phq_assessment
  @phq_assessment.destroy
  redirect_to(
    coach_phq_assessments_url(participant_id: @participant.id),
    notice: "Phq assessment was successfully destroyed."
  )
end

#editObject

GET /coach/phq_assessments/1/edit



25
26
27
# File 'app/controllers/think_feel_do_engine/coach/phq_assessments_controller.rb', line 25

def edit
  authorize! :edit, @phq_assessment
end

#indexObject

GET /coach/phq_assessments



13
14
15
16
# File 'app/controllers/think_feel_do_engine/coach/phq_assessments_controller.rb', line 13

def index
  @phq_assessments = @participant.phq_assessments
  authorize! :index, PhqAssessment
end

#newObject

GET /coach/phq_assessments/new



19
20
21
22
# File 'app/controllers/think_feel_do_engine/coach/phq_assessments_controller.rb', line 19

def new
  @phq_assessment = @participant.phq_assessments.build
  authorize! :new, @phq_assessment
end

#updateObject

PATCH/PUT /coach/phq_assessments/1



47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/think_feel_do_engine/coach/phq_assessments_controller.rb', line 47

def update
  authorize! :update, @phq_assessment
  if @phq_assessment.update(coach_phq_assessment_params)
    redirect_to(
      coach_phq_assessments_url(participant_id: @participant.id),
      notice: "Phq assessment was successfully updated."
    )
  else
    render :edit
  end
end