diff --git a/app/controllers/budgets/results_controller.rb b/app/controllers/budgets/results_controller.rb index 8da1e9ef7..96f52b8ca 100644 --- a/app/controllers/budgets/results_controller.rb +++ b/app/controllers/budgets/results_controller.rb @@ -1,22 +1,31 @@ module Budgets class ResultsController < ApplicationController + before_action :load_budget + before_action :load_heading load_and_authorize_resource :budget def show authorize! :read_results, @budget @investments = load_result.investments - @heading = heading end private def load_result - Budget::Result.new(@budget, heading) + Budget::Result.new(@budget, @heading) end - def heading - @budget.headings.find(params[:heading_id]) + def load_budget + @budget = Budget.find_by(id: params[:budget_id]) + end + + def load_heading + if params[:heading_id].present? + @heading = @budget.headings.find(params[:heading_id]) + else + @heading = @budget.headings.first + end end end diff --git a/app/views/budgets/results/show.html.erb b/app/views/budgets/results/show.html.erb index eb31124ec..0733b6ce1 100644 --- a/app/views/budgets/results/show.html.erb +++ b/app/views/budgets/results/show.html.erb @@ -1,6 +1,13 @@ <% provide :title, t("budgets.results.page_title", budget: @budget.name) %> +<% content_for :meta_description do %><%= @budget.description_finished %><% end %> +<% provide :social_media_meta_tags do %> +<%= render "shared/social_media_meta_tags", + social_url: budget_results_url(@budget), + social_title: @budget.name, + social_description: @budget.description_finished %> +<% end %> <% content_for :canonical do %> - <%= render "shared/canonical", href: budget_results_url(@budget, heading_id: @heading) %> + <%= render "shared/canonical", href: budget_results_url(@budget) %> <% end %>