Added interface and methods for edit the name of a Budget::Group if the budget is still inthe drafting phase

This commit is contained in:
Raúl Fuentes
2018-02-13 13:51:47 +01:00
committed by Bertocq
parent 089cef8ead
commit 6d8d44a5e3
10 changed files with 62 additions and 19 deletions

View File

@@ -8,10 +8,22 @@ class Admin::BudgetGroupsController < Admin::BaseController
@groups = @budget.groups.includes(:headings)
end
def update
@group = Budget::Group.by_slug(params[:id]).first
if @group.generate_slug?
params[:id] = @group.generate_slug
end
@group.update(budget_group_params)
end
private
def budget_group_params
params.require(:budget_group).permit(:name)
end
end
def load_budget
@budget = Budget.find_by(slug: params[:budget_id]) || Budget.find_by(id: params[:budget_id])
end
end