Sha256: b1a13937879da1ae193e68203364a774177ba9a6884a1b7f55b2f0719892b2fa
Contents?: true
Size: 1.76 KB
Versions: 9
Compression:
Stored size: 1.76 KB
Contents
# frozen_string_literal: true module MrCommon module Registrations class RegistrationsController < BaseController def index @registrations = Registration.order(first_name: :asc, last_name: :asc) end def show @registration = Registration.find(params[:id]) end def new @registration = Registration.new end def create @registration = Registration.new(registration_params) if @registration.save redirect_to registrations_path, notice: "Registration saved." else flash.now[:alert] = MrCommon.registration_failure_alert render :new, status: :unprocessable_entity end end def edit @registration = Registration.find(params[:id]) end def update @registration = Registration.find(params[:id]) if @registration.update(registration_params) redirect_to @registration, notice: "Registration saved." else flash.now[:alert] = MrCommon.registration_failure_alert render :new, status: :unprocessable_entity end end def destroy @registration = Registration.find(params[:id]) if @registration.destroy redirect_to registrations_path, notice: "Registration destroyed." else redirect_to @registration, alert: "Unable to destroy Registration." end end private 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
9 entries across 9 versions & 1 rubygems