Sha256: 57ccbafe7679ba76e06010094c2e1c7544aabf8c3eaa1c51394c288ec55a38bc

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 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]).by_newest
      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,
          :fee,
          :enable_price_from,
          :enable_price_to
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comable-backend-0.7.1 app/controllers/comable/admin/payment_methods_controller.rb
comable-backend-0.7.0 app/controllers/comable/admin/payment_methods_controller.rb
comable-backend-0.7.0.beta2 app/controllers/comable/admin/payment_methods_controller.rb