Sha256: ab7d761e93904a45113f58a055f885dc4d0b066941cd3e99f4351fa7d204c729

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Lcms
  module Engine
    class SurveysController < Lcms::Engine::ApplicationController
      skip_before_action :check_user_has_survey_filled_in

      def create
        @form = SurveyForm.new(permitted_params)
        if @form.valid?
          current_user.update(survey: @form.attributes)
          loc = stored_location_for(:user)
          loc = lcms_engine.root_path if loc.is_a?(String) && loc[survey_path]
          redirect_to loc || lcms_engine.root_path
        else
          render :show
        end
      end

      def show
        return redirect_to lcms_engine.root_path if current_user.ready_to_go?

        @form = SurveyForm.new(current_user.survey)
      end

      private

      def permitted_params
        params.require(:survey_form).permit(
          :additional_period,
          :additional_period_minutes,
          :district_or_system,
          :district_or_system_other,
          :first_name,
          :last_name,
          :number_of_minutes,
          :prior_experience,
          :subject_or_grade,
          :subject_or_grade_other
        )
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 app/controllers/lcms/engine/surveys_controller.rb
lcms-engine-0.5.4 app/controllers/lcms/engine/surveys_controller.rb
lcms-engine-0.5.3 app/controllers/lcms/engine/surveys_controller.rb
lcms-engine-0.5.2 app/controllers/lcms/engine/surveys_controller.rb
lcms-engine-0.5.1 app/controllers/lcms/engine/surveys_controller.rb
lcms-engine-0.5.0 app/controllers/lcms/engine/surveys_controller.rb
lcms-engine-0.4.2 app/controllers/lcms/engine/surveys_controller.rb
lcms-engine-0.4.1 app/controllers/lcms/engine/surveys_controller.rb
lcms-engine-0.4.0 app/controllers/lcms/engine/surveys_controller.rb
lcms-engine-0.3.1 app/controllers/lcms/engine/surveys_controller.rb
lcms-engine-0.3.0 app/controllers/lcms/engine/surveys_controller.rb