Create description_for_phase helper method at Budget, to make it easier to get non-active-phase description

This commit is contained in:
Bertocq
2018-01-15 16:48:26 +01:00
parent 5016568b8a
commit 153b46b468
2 changed files with 6 additions and 2 deletions

View File

@@ -34,6 +34,10 @@ class Budget < ActiveRecord::Base
scope :current, -> { where.not(phase: "finished") }
def description
description_for_phase(phase)
end
def description_for_phase(phase)
send("description_#{phase}").try(:html_safe)
end

View File

@@ -1,10 +1,10 @@
<% provide :title, t("budgets.results.page_title", budget: @budget.name) %>
<% content_for :meta_description do %><%= @budget.description_finished %><% end %>
<% content_for :meta_description do %><%= @budget.description_for_phase('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 %>
social_description: @budget.description_for_phase('finished') %>
<% end %>
<% content_for :canonical do %>
<%= render "shared/canonical", href: budget_results_url(@budget) %>