Clear instance variable names help understand what's going around when you're deep 2 or 3 partials. In this case @budget is only used to carry around the current_budget so @current_budget is more descriptive. Using `current_budget` directly around would be an alternative, but maybe not as maintainable in case we want to change which budget is being shown (for example the drafting one if you're admin).
23 lines
607 B
Ruby
23 lines
607 B
Ruby
class BudgetsController < ApplicationController
|
|
include FeatureFlags
|
|
include BudgetsHelper
|
|
feature_flag :budgets
|
|
|
|
load_and_authorize_resource
|
|
before_action :set_default_budget_filter, only: :show
|
|
has_filters %w{not_unfeasible feasible unfeasible unselected selected}, only: :show
|
|
|
|
respond_to :html, :js
|
|
|
|
def show
|
|
raise ActionController::RoutingError, 'Not Found' unless budget_published?(@budget)
|
|
end
|
|
|
|
def index
|
|
@finished_budgets = @budgets.finished.order(created_at: :desc)
|
|
@current_budget = current_budget
|
|
@budgets_coordinates = current_budget_map_locations
|
|
end
|
|
|
|
end
|