From b66c2b1f36df3280a325ba872eaea512c8b233f0 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 12 Jan 2023 18:23:48 +0100 Subject: [PATCH] add `long?` method and constant to Answer model --- app/models/answer.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/answer.rb b/app/models/answer.rb index 587db426..91a6c956 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -14,6 +14,8 @@ class Answer < ApplicationRecord validates :question_id, uniqueness: { scope: :user_id } # rubocop:enable Rails/UniqueValidationWithoutIndex + SHORT_ANSWER_MAX_LENGTH = 640 + # rubocop:disable Rails/SkipsModelValidations after_create do Inbox.where(user: self.user, question: self.question).destroy_all @@ -52,4 +54,6 @@ class Answer < ApplicationRecord def notification_type(*_args) Notification::QuestionAnswered end + + def long? = content.length > SHORT_ANSWER_MAX_LENGTH end