Sha256: 246d46e1c02bc383897a4e6508b0b4a670cf296388635621b1b49476e766ee1f

Contents?: true

Size: 1.69 KB

Versions: 51

Compression:

Stored size: 1.69 KB

Contents

require_dependency "think_feel_do_engine/application_controller"

module ThinkFeelDoEngine
  module Participants
    # Manage Participant Activities.
    class ActivitiesController < ApplicationController
      before_action :authenticate_participant!
      before_action :set_activity, only: [:update]

      # refactor...
      def create
        @activity = current_participant.activities.find(activity_id)
        @activity.update(activity_params)
      end
      # ...

      def update
        if @activity.update_as_reviewed(activity_params_for_update)
          flash[:notice] = "Activity updated."
          respond_to do |format|
            format.js { render inline: "Turbolinks.visit(window.location);" }
          end
        else
          flash[:alert] = @activity.errors.full_messages.join(", ")
          respond_to do |format|
            format.js { render inline: "Turbolinks.visit(window.location);" }
          end
        end
      end

      private

      # TODO: refactor and remove route...
      def activity_id
        params[:activities][:commit_id].keys.first || -1
      end

      def activity_params
        params.require(:activities)
          .permit(activity_id => [
            :actual_pleasure_intensity,
            :actual_accomplishment_intensity
          ])
          .fetch(activity_id)
      end
      # ...

      def set_activity
        @activity = current_participant
                    .activities
                    .find(params[:id])
      end

      def activity_params_for_update
        params
          .require(:activity)
          .permit(
            :actual_pleasure_intensity,
            :actual_accomplishment_intensity
          )
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
think_feel_do_engine-3.19.9 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.19.8 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.19.7 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.19.6 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.19.5 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.19.4 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.19.3 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.19.2 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.19.1 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.19.0 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.18.0 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.17.2 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.17.1 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.17.0 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.16.3 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.16.2 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.16.1 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.15.7 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.16.0 app/controllers/think_feel_do_engine/participants/activities_controller.rb
think_feel_do_engine-3.15.6 app/controllers/think_feel_do_engine/participants/activities_controller.rb