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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user