23 行
871 B
Ruby
23 行
871 B
Ruby
class GekanatorQuestion < ApplicationRecord
|
|
KINDS = ['tag', 'source', 'title', 'original_date'].freeze
|
|
SOURCES = ['user_suggested', 'ai_generated', 'admin_curated'].freeze
|
|
STATUSES = ['pending', 'accepted', 'rejected'].freeze
|
|
|
|
belongs_to :gekanator_question_suggestion, optional: true
|
|
belongs_to :created_by, class_name: 'User', optional: true
|
|
|
|
validates :kind, presence: true, inclusion: { in: KINDS }
|
|
validates :source, presence: true, inclusion: { in: SOURCES }
|
|
validates :status, presence: true, inclusion: { in: STATUSES }
|
|
validates :text, presence: true, length: { maximum: 1000 }
|
|
validates :condition, presence: true
|
|
validates :priority_weight,
|
|
presence: true,
|
|
numericality: {
|
|
greater_than: 0,
|
|
less_than_or_equal_to: 3
|
|
}
|
|
|
|
scope :accepted, -> { where(status: 'accepted') }
|
|
end
|