From 63b79c302c023f325ca9c98c8e541ed7f21f3b9d Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 22 Jul 2025 10:10:44 -0400 Subject: [PATCH] Add to_label to preset warning model --- app/models/account_warning_preset.rb | 8 ++++++++ 1 file changed, 8 insertions(+) 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