Replace manual activerecord translations with helpers

This commit is contained in:
Sebastian Serth
2024-04-14 14:00:51 +02:00
committed by Sebastian Serth
parent e551c8a699
commit f8330b39fb
72 changed files with 265 additions and 264 deletions

View File

@@ -13,16 +13,15 @@ class Tip < ApplicationRecord
unless [
description?, example?
].include?(true)
errors.add :description,
I18n.t('activerecord.errors.messages.at_least', attribute: I18n.t('activerecord.attributes.tip.example'))
errors.add :description, :at_least, attribute: Tip.human_attribute_name('example')
end
end
def to_s
if title?
"#{I18n.t('activerecord.models.tip.one')}: #{title} (#{id})"
"#{Tip.model_name.human}: #{title} (#{id})"
else
"#{I18n.t('activerecord.models.tip.one')} #{id}"
"#{Tip.model_name.human} #{id}"
end
end