diff --git a/app/models/account_warning_preset.rb b/app/models/account_warning_preset.rb index c20f683cff9..4e56bb49258 100644 --- a/app/models/account_warning_preset.rb +++ b/app/models/account_warning_preset.rb @@ -12,7 +12,15 @@ # class AccountWarningPreset < ApplicationRecord + LABEL_TEXT_LENGTH = 30 + validates :text, presence: true scope :alphabetic, -> { order(title: :asc, text: :asc) } + + def to_label + [title.presence, text.to_s.truncate(LABEL_TEXT_LENGTH)] + .compact + .join(' - ') + end end