foodsoft/app/controllers/admin/bank_accounts_controller.rb

42 lines
1.1 KiB
Ruby
Raw Normal View History

2018-09-14 19:33:27 +02:00
class Admin::BankAccountsController < Admin::BaseController
inherit_resources
def new
@bank_account = BankAccount.new(params[:bank_account])
render layout: false
end
def edit
@bank_account = BankAccount.find(params[:id])
render action: 'new', layout: false
2018-09-14 19:33:27 +02:00
end
def create
@bank_account = BankAccount.new(params[:bank_account])
if @bank_account.valid? && @bank_account.save
redirect_to update_bank_accounts_admin_finances_url, status: :see_other
2018-09-14 19:33:27 +02:00
else
render action: 'new', layout: false
2018-09-14 19:33:27 +02:00
end
end
def update
@bank_account = BankAccount.find(params[:id])
if @bank_account.update(params[:bank_account])
redirect_to update_bank_accounts_admin_finances_url, status: :see_other
2018-09-14 19:33:27 +02:00
else
render action: 'new', layout: false
2018-09-14 19:33:27 +02:00
end
end
def destroy
@bank_account = BankAccount.find(params[:id])
@bank_account.destroy
redirect_to update_bank_accounts_admin_finances_url, status: :see_other
rescue StandardError => e
flash.now[:alert] = e.message
2018-09-14 19:33:27 +02:00
render template: 'shared/alert'
end
end