Sha256: 01a59c94c1fee2a6375ff3515282f2e2a5b8560a7f2198ec31bd8f09ca40a0a5

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 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 create
        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 :new
        end
      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

3 entries across 3 versions & 1 rubygems

Version Path
comable_backend-0.3.2 app/controllers/comable/admin/payment_methods_controller.rb
comable_backend-0.3.1 app/controllers/comable/admin/payment_methods_controller.rb
comable_backend-0.3.0 app/controllers/comable/admin/payment_methods_controller.rb