mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-15 23:20:01 +01:00
add long?
method and constant to Answer model
This commit is contained in:
parent
4692753485
commit
b66c2b1f36
1 changed files with 4 additions and 0 deletions
|
@ -14,6 +14,8 @@ class Answer < ApplicationRecord
|
||||||
validates :question_id, uniqueness: { scope: :user_id }
|
validates :question_id, uniqueness: { scope: :user_id }
|
||||||
# rubocop:enable Rails/UniqueValidationWithoutIndex
|
# rubocop:enable Rails/UniqueValidationWithoutIndex
|
||||||
|
|
||||||
|
SHORT_ANSWER_MAX_LENGTH = 640
|
||||||
|
|
||||||
# rubocop:disable Rails/SkipsModelValidations
|
# rubocop:disable Rails/SkipsModelValidations
|
||||||
after_create do
|
after_create do
|
||||||
Inbox.where(user: self.user, question: self.question).destroy_all
|
Inbox.where(user: self.user, question: self.question).destroy_all
|
||||||
|
@ -52,4 +54,6 @@ class Answer < ApplicationRecord
|
||||||
def notification_type(*_args)
|
def notification_type(*_args)
|
||||||
Notification::QuestionAnswered
|
Notification::QuestionAnswered
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def long? = content.length > SHORT_ANSWER_MAX_LENGTH
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue