Sha256: 8a3be014077662e5be30fd74ce7618815277d4f4f58548c6a68a91c9b2780d65

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Lcms
  module Engine
    module Admin
      class AccessCodesController < AdminController
        before_action :set_resource, except: %i(index new create)

        def create
          @access_code = AccessCode.new(permitted_params)
          if @access_code.save
            redirect_to({ action: :index }, notice: t('.success'))
          else
            render :new
          end
        end

        def destroy
          @access_code.destroy
          redirect_to({ action: :index }, notice: t('.success'))
        end

        def index
          @access_codes = AccessCode.order(code: :asc).paginate(page: params[:page])
        end

        def new
          @access_code = AccessCode.new
        end

        def update
          if @access_code.update(permitted_params)
            redirect_to({ action: :index }, notice: t('.success'))
          else
            render :edit
          end
        end

        private

        def permitted_params
          params.require(:access_code).permit(:active, :code)
        end

        def set_resource
          @access_code = AccessCode.find(params[:id])
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lcms-engine-0.3.1 app/controllers/lcms/engine/admin/access_codes_controller.rb
lcms-engine-0.1.4 app/controllers/lcms/engine/admin/access_codes_controller.rb
lcms-engine-0.3.0 app/controllers/lcms/engine/admin/access_codes_controller.rb
lcms-engine-0.1.3 app/controllers/lcms/engine/admin/access_codes_controller.rb
lcms-engine-0.2.0 app/controllers/lcms/engine/admin/access_codes_controller.rb
lcms-engine-0.1.2 app/controllers/lcms/engine/admin/access_codes_controller.rb
lcms-engine-0.1.0 app/controllers/lcms/engine/admin/access_codes_controller.rb