Added admin budget phases controller and routes

This commit is contained in:
María Checa
2018-01-18 21:32:58 +01:00
parent 26656a8dfd
commit 1abb7f0310
3 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
class Admin::BudgetPhasesController < Admin::BaseController
before_action :load_phase, only: [:edit, :update]
def edit; end
def update
if @phase.update(budget_phase_params)
redirect_to edit_admin_budget_path(@phase.budget), notice: t("flash.actions.save_changes.notice")
else
render :edit
end
end
private
def load_phase
@phase = Budget::Phase.find(params[:id])
end
def budget_phase_params
valid_attributes = [:starts_at, :ends_at, :summary, :description, :enabled]
params.require(:budget_phase).permit(*valid_attributes)
end
end