Sha256: 0b067d36a532da14550f5aa4d7bc7cf1f3bbe75cb60f339dbe06a7adb152a2e4

Contents?: true

Size: 1.69 KB

Versions: 13

Compression:

Stored size: 1.69 KB

Contents

require_dependency "think_feel_do_dashboard/application_controller"

module ThinkFeelDoDashboard
  # Allows for the creation, updating, and deletion of participants
  class ParticipantsController < ApplicationController
    load_and_authorize_resource
    before_action :set_contact_preferences

    # GET /think_feel_do_dashboard/participants
    def index
    end

    # POST /think_feel_do_dashboard/participants
    def create
      if @participant.save
        redirect_to @participant,
                    notice: "Participant was successfully created."
      else
        render :new
      end
    end

    # GET /think_feel_do_dashboard/participants/new
    def new
    end

    # GET /think_feel_do_dashboard/participants/1
    def show
    end

    # GET /think_feel_do_dashboard/participants/1/edit
    def edit
    end

    # PATCH/PUT /think_feel_do_dashboard/participants/1
    def update
      if @participant.update(participant_params)
        redirect_to participant_path(@participant),
                    notice: "Participant was successfully updated.",
                    only: true
      else
        render :edit
      end
    end

    # DELETE /think_feel_do_dashboard/participants/1
    def destroy
      @participant.destroy
      redirect_to participants_url,
                  notice: "Participant was successfully destroyed."
    end

    private

    def set_contact_preferences
      @contact_preferences = [
        ["Email", "email"],
        ["Phone", "phone"]
      ]
    end

    def participant_params
      params.require(:participant).permit(
        :email, :phone_number, :display_name,
        :study_id, :contact_preference, :password, :password_confirmation
      )
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
think_feel_do_dashboard-1.2.0.beta1 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.21 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.20 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.19 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.18 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.17 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.16 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.15 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.14 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.13 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.12 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.11 app/controllers/think_feel_do_dashboard/participants_controller.rb
think_feel_do_dashboard-1.1.10 app/controllers/think_feel_do_dashboard/participants_controller.rb