Files
nairobi/app/controllers/budgets_controller.rb
Julian Herrero 7e3dd47d5a Unify budget landing pages
There was a big difference between the current budget and a specific
budget landing page. This didn't really make too much sense. Also, it
was not possible to know how a draft participatory budget will look
before it was published.

By unifying those two views now they will look quite similar and it
will be possible for administrators to preview any draft budget and to
know how the budget will look like before actually publishing it.
2021-03-18 15:03:21 +01:00

30 lines
627 B
Ruby

class BudgetsController < ApplicationController
include FeatureFlags
include BudgetsHelper
feature_flag :budgets
before_action :load_budget, only: :show
before_action :load_current_budget, only: :index
load_and_authorize_resource
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)
end
private
def load_budget
@budget = Budget.find_by_slug_or_id! params[:id]
end
def load_current_budget
@budget = current_budget
end
end