Class: ThinkFeelDoDashboard::CoachAssignmentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/think_feel_do_dashboard/coach_assignments_controller.rb

Overview

Used to associated coaches with participants

Instance Method Summary collapse

Instance Method Details

#createObject

POST /think_feel_do_dashboard/participants/1/coaches



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/think_feel_do_dashboard/coach_assignments_controller.rb', line 17

def create
  authorize! :create, CoachAssignment
  @coach_assignment = @participant.build_coach_assignment(
    coach_assignment_params
  )

  if @coach_assignment.save
    redirect_to participant_path(@participant),
                notice: "Coach/Moderator was successfully assigned."
  else
    render :new
  end
end

#destroyObject

DELETE /think_feel_do_dashboard/participants/1/coaches/1



55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/think_feel_do_dashboard/coach_assignments_controller.rb', line 55

def destroy
  authorize! :destroy, @coach_assignment
  if @coach_assignment.destroy
    redirect_to participant_path(@participant),
                notice: "Coach/Moderator was successfully removed."
  else
    redirect_to participant_path(@participant),
                alert: "There were errors."
  end
end

#editObject

GET /think_feel_do_dashboard/participants/1/coaches/1/edit



37
38
39
# File 'app/controllers/think_feel_do_dashboard/coach_assignments_controller.rb', line 37

def edit
  authorize! :edit, @coach_assignment
end

#newObject

GET /think_feel_do_dashboard/participants/1/coaches/new



12
13
14
# File 'app/controllers/think_feel_do_dashboard/coach_assignments_controller.rb', line 12

def new
  authorize! :new, CoachAssignment
end

#showObject

GET /think_feel_do_dashboard/participants/1/coaches/1



32
33
34
# File 'app/controllers/think_feel_do_dashboard/coach_assignments_controller.rb', line 32

def show
  authorize! :read, @coach_assignment
end

#updateObject

PATCH/PUT /think_feel_do_dashboard/participants/1/coaches/1



42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/think_feel_do_dashboard/coach_assignments_controller.rb', line 42

def update
  authorize! :update, @coach_assignment
  if @coach_assignment.update(coach_assignment_params)
    redirect_to participant_path(
      @participant
    ),
                notice: "Coach/Moderator was successfully assigned."
  else
    render :edit
  end
end

#wozObject

GET /think_feel_do_dashboard/participants/1/coaches/woz



67
68
69
70
71
72
73
74
75
76
77
# File 'app/controllers/think_feel_do_dashboard/coach_assignments_controller.rb', line 67

def woz
  if @participant.coach
    set_coach_assignment
    authorize! :edit, @coach_assignment

    update_woz_coach
  else
    authorize! :new, CoachAssignment
    set_new_woz_coach
  end
end