Sha256: 2d0a1ffc332b4361332a4c8c00c75914048563eb758e1b6139311225d18c3cb4

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require_dependency 'comable/admin/application_controller'

module Comable
  module Admin
    class PaymentMethodsController < Comable::Admin::ApplicationController
      load_and_authorize_resource class: Comable::PaymentMethod.name

      def index
        @payment_methods = @payment_methods.page(params[:page])
      end

      def show
        render :edit
      end

      def new
      end

      def create
        if @payment_method.save
          redirect_to comable.admin_payment_method_path(@payment_method), notice: Comable.t('successful')
        else
          flash.now[:alert] = Comable.t('failure')
          render :new
        end
      end

      def edit
      end

      def update
        if @payment_method.update_attributes(payment_method_params)
          redirect_to comable.admin_payment_method_path(@payment_method), notice: Comable.t('successful')
        else
          flash.now[:alert] = Comable.t('failure')
          render :edit
        end
      end

      def destroy
        @payment_method.destroy
        redirect_to comable.admin_payment_methods_path, notice: Comable.t('successful')
      end

      private

      def payment_method_params
        params.require(:payment_method).permit(
          :name,
          :payment_provider_type,
          :payment_provider_kind,
          :enable_price_from,
          :enable_price_to
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
comable_backend-0.3.4 app/controllers/comable/admin/payment_methods_controller.rb
comable_backend-0.3.3 app/controllers/comable/admin/payment_methods_controller.rb