mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-18 20:59:39 +02:00
* Add breadcrumbs support across application Fixes #1896 * Potential fix for tests * Simplify breadcrumbs implementation Remove complex breadcrumbs logic from controllers and concern, replacing with a simpler default approach that sets a basic breadcrumb based on the current controller name * Refactor page header and breadcrumbs rendering Remove complex breadcrumbs helper method and update layout to use more flexible content_for approach for page headers and breadcrumbs * Add fallback breadcrumbs rendering to settings layout
47 lines
1.1 KiB
Ruby
47 lines
1.1 KiB
Ruby
class BudgetsController < ApplicationController
|
|
before_action :set_budget, only: %i[show edit update]
|
|
|
|
def index
|
|
redirect_to_current_month_budget
|
|
end
|
|
|
|
def show
|
|
end
|
|
|
|
def edit
|
|
render layout: "wizard"
|
|
end
|
|
|
|
def update
|
|
@budget.update!(budget_params)
|
|
redirect_to budget_budget_categories_path(@budget)
|
|
end
|
|
|
|
def picker
|
|
render partial: "budgets/picker", locals: {
|
|
family: Current.family,
|
|
year: params[:year].to_i || Date.current.year
|
|
}
|
|
end
|
|
|
|
private
|
|
|
|
def budget_create_params
|
|
params.require(:budget).permit(:start_date)
|
|
end
|
|
|
|
def budget_params
|
|
params.require(:budget).permit(:budgeted_spending, :expected_income)
|
|
end
|
|
|
|
def set_budget
|
|
start_date = Budget.param_to_date(params[:month_year])
|
|
@budget = Budget.find_or_bootstrap(Current.family, start_date: start_date)
|
|
raise ActiveRecord::RecordNotFound unless @budget
|
|
end
|
|
|
|
def redirect_to_current_month_budget
|
|
current_budget = Budget.find_or_bootstrap(Current.family, start_date: Date.current)
|
|
redirect_to budget_path(current_budget)
|
|
end
|
|
end
|