From 799b96cc40e7e4e40bd3e28513f6d632db9b91a8 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 8 Jan 2018 17:49:29 +0100 Subject: [PATCH] Add destroy action to admin budget controller --- app/controllers/admin/budgets_controller.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/controllers/admin/budgets_controller.rb b/app/controllers/admin/budgets_controller.rb index 7caf4f35c..2d6fc7d8f 100644 --- a/app/controllers/admin/budgets_controller.rb +++ b/app/controllers/admin/budgets_controller.rb @@ -42,6 +42,15 @@ class Admin::BudgetsController < Admin::BaseController end end + def destroy + if @budget.investments.any? + redirect_to admin_budgets_path, alert: t('admin.budgets.destroy.unable_notice') + else + @budget.destroy + redirect_to admin_budgets_path, notice: t('admin.budgets.destroy.success_notice') + end + end + private def budget_params