Files
nairobi/app/models/sdg/goal.rb
Javi Martín 159edba015 Specify the SDG title uses two lines
This way translators will find a hint indicating they must use two lines
and not three or more, since the title is optimized for being displayed
in two lines.
2021-01-04 12:45:03 +01:00

28 lines
512 B
Ruby

class SDG::Goal < ApplicationRecord
include SDG::Related
validates :code, presence: true, uniqueness: true, inclusion: { in: 1..17 }
has_many :targets, dependent: :destroy
def title
I18n.t("sdg.goals.goal_#{code}.title")
end
def title_in_two_lines
I18n.t("sdg.goals.goal_#{code}.title_in_two_lines")
end
def description
I18n.t("sdg.goals.goal_#{code}.description")
end
def self.[](code)
find_by!(code: code)
end
def code_and_title
"#{code}. #{title}"
end
end