Extract method to display a goal code and title

This is a pattern we're going to use in many places.
This commit is contained in:
Javi Martín
2020-12-17 18:40:52 +01:00
parent cb183b6e15
commit 791ba73e12
2 changed files with 5 additions and 1 deletions

View File

@@ -13,7 +13,7 @@
<% targets.group_by(&:goal).map do |goal, targets| %>
<tr class="goal-header">
<th id="<%= header_id(goal) %>" colspan="2" scope="colgroup">
<%= goal.code %>. <%= goal.title %>
<%= goal.code_and_title %>
</th>
</tr>

View File

@@ -16,4 +16,8 @@ class SDG::Goal < ApplicationRecord
def self.[](code)
find_by!(code: code)
end
def code_and_title
"#{code}. #{title}"
end
end