Sha256: cf2e5a08e3e7ade1a561a73721151e7153a51da9cdc67f81df0771c15695f145
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
# frozen_string_literal: true module MrCommon module Registrations # Implements public Registration actions available from the landing page. class PublicController < PublicBaseController def new @registration = Registration.new end def create @registration = Registration.new(registration_params) @registration.confirmed = true if should_confirm_registration? if @registration.save send_notification redirect_to registrations_success_index_path, notice: MrCommon.registration_success_notice else flash.now[:alert] = MrCommon.registration_failure_alert if MrCommon.registration_failure_alert.present? render :new, status: :unprocessable_entity end end private def should_confirm_registration? case MrCommon.registration_confirmation_strategy when :auto true when :pre_register PreRegistration.exists_for?(@registration) when :manual false else false end end def send_notification if @registration.confirmed? RegistrationMailer.confirmed_registration(@registration.id).deliver_now else RegistrationMailer.unconfirmed_registration(@registration.id).deliver_now end end def registration_params params.require( :registration ).permit( :first_name, :last_name, :email, :company_name, :telephone, :job_title, :contact_via_email, :contact_via_phone, ) 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/registrations/public_controller.rb |
mr_common-2.0.0 | app/controllers/mr_common/registrations/public_controller.rb |