backend/app/controllers/comable/admin/payment_methods_controller.rb
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