Sha256: b884e6c7efe5853fff15fcc53fa423758f163b062e3233910e1389239f2922f8

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module MrCommon
  module PreRegistrations
    class PreRegistrationsController < BaseController
      def index
        @pre_registration = PreRegistration.order(email: :asc)
      end

      def new
        @pre_registration = PreRegistration.new
      end

      def create
        @pre_registration = PreRegistration.new(pre_registration_params)

        if @pre_registration.save
          redirect_to pre_registrations_path, notice: "Pre-registration saved."
        else
          flash.now[:alert] = "There was a problem saving the pre-registration."
          render :new, status: :unprocessable_entity
        end
      end

      def destroy
        @pre_registration = PreRegistration.find(params[:id])

        if @pre_registration.destroy
          redirect_to pre_registrations_path, notice: "Pre-registration deleted."
        else
          redirect_to pre_registrations_path, notice: "There was a problem deleting the pre-registration."
        end
      end

      private

        def pre_registration_params
          params.require(
            :confirmed_registration
          ).permit(
            :email,
            :first_name,
            :last_name
          )
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mr_common-2.1.0 app/controllers/mr_common/pre_registrations/pre_registrations_controller.rb
mr_common-2.0.0 app/controllers/mr_common/pre_registrations/pre_registrations_controller.rb