Class: ThinkFeelDoEngine::MembershipsController

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

Overview

Allows a clinician to END a participant’s study

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

#discontinueObject



33
34
35
36
37
38
39
40
41
# File 'app/controllers/think_feel_do_engine/memberships_controller.rb', line 33

def discontinue
  if @membership.discontinue
    flash[:notice] = "Membership successfully ended"
  else
    flash[:alert] = @membership.errors.full_messages.to_sentence
  end

  redirect_to coach_group_patient_dashboards_path(@membership.group)
end

#updateObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/think_feel_do_engine/memberships_controller.rb', line 11

def update
  if @membership.update(membership_params)
    flash[:notice] = "Membership successfully updated"
  else
    flash[:alert] = "Unable to save membership changes. End date cannot "\
    " be set prior to tomorrow's date. Please use [Discontinue] or "\
    "[Terminate Access]."
  end

  redirect_to coach_group_patient_dashboards_path(@membership.group)
end

#withdrawObject



23
24
25
26
27
28
29
30
31
# File 'app/controllers/think_feel_do_engine/memberships_controller.rb', line 23

def withdraw
  if @membership.withdraw
    flash[:notice] = "Membership successfully withdrawn"
  else
    flash[:alert] = @membership.errors.full_messages.to_sentence
  end

  redirect_to coach_group_patient_dashboards_path(@membership.group)
end