Class: ThinkFeelDoDashboard::MembershipsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- ThinkFeelDoDashboard::MembershipsController
- Defined in:
- app/controllers/think_feel_do_dashboard/memberships_controller.rb
Overview
Assigns a participant with a group along with setting the start and end date
Instance Method Summary collapse
-
#create ⇒ Object
POST /think_feel_do_dashboard/participants/1/groups.
-
#destroy ⇒ Object
DELETE /think_feel_do_dashboard/participants/1/groups/1.
-
#edit ⇒ Object
GET /think_feel_do_dashboard/participants/1/groups/1/edit.
-
#index ⇒ Object
GET /think_feel_do_dashboard/participants/1/groups.
-
#new ⇒ Object
GET /think_feel_do_dashboard/participants/1/groups/new.
-
#show ⇒ Object
GET /think_feel_do_dashboard/participants/1/groups/1.
-
#update ⇒ Object
PATCH/PUT /think_feel_do_dashboard/participants/1/groups/1.
Instance Method Details
#create ⇒ Object
POST /think_feel_do_dashboard/participants/1/groups
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/think_feel_do_dashboard/memberships_controller.rb', line 21 def create @membership = @participant .memberships .build(membership_params) :create, @membership if && @membership.save redirect_to participant_path(@participant), notice: "Group was successfully assigned" else render :new end end |
#destroy ⇒ Object
DELETE /think_feel_do_dashboard/participants/1/groups/1
63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/think_feel_do_dashboard/memberships_controller.rb', line 63 def destroy :destroy, @membership if @membership.destroy redirect_to participant_path(@participant), notice: "Group was successfully removed." else redirect_to participant_path(@participant), alert: "There were errors." end end |
#edit ⇒ Object
GET /think_feel_do_dashboard/participants/1/groups/1/edit
43 44 45 |
# File 'app/controllers/think_feel_do_dashboard/memberships_controller.rb', line 43 def edit :edit, @membership end |
#index ⇒ Object
GET /think_feel_do_dashboard/participants/1/groups
10 11 12 |
# File 'app/controllers/think_feel_do_dashboard/memberships_controller.rb', line 10 def index :index, Membership end |
#new ⇒ Object
GET /think_feel_do_dashboard/participants/1/groups/new
15 16 17 18 |
# File 'app/controllers/think_feel_do_dashboard/memberships_controller.rb', line 15 def new @membership = @participant.memberships.build :new, @membership end |
#show ⇒ Object
GET /think_feel_do_dashboard/participants/1/groups/1
36 37 38 39 40 |
# File 'app/controllers/think_feel_do_dashboard/memberships_controller.rb', line 36 def show redirect_to participant_path(@participant), alert: "Membership not found." if @membership.nil? :show, @membership end |
#update ⇒ Object
PATCH/PUT /think_feel_do_dashboard/participants/1/groups/1
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/think_feel_do_dashboard/memberships_controller.rb', line 48 def update :update, @membership if @membership.update(membership_params) redirect_to participant_path(@participant), notice: "Group assignment was successfully updated." else flash[:alert] = @membership.errors..join(", ") flash[:alert] += "End date cannot be set prior to tomorrow's date. " \ "Please use [Discontinue] or [Terminate Access] " \ "from the patient dashboard." render :edit end end |