Sha256: 17a5ea8b3b74a58165b89c0c345d740b8e7d1c835a4f8328c679e51483486b7d
Contents?: true
Size: 1.02 KB
Versions: 42
Compression:
Stored size: 1.02 KB
Contents
require 'subj_models/concerns/comprising_external_id' module SubjModels module FaqModule include SubjModels::TypesSupport::FaqTypes include SubjModels::ValuesChecker def self.included(including_class) including_class.class_eval do include SubjModels::ComprisingExternalId enum faq_type: FAQ_TYPES after_save :notify_user validates :question, presence: true, allow_blank: false, uniqueness: { message: 'Простите, такой вопрос уже был задан' } validates :faq_type, inclusion: { in: faq_types.keys }, on: :update scope :with_answer, -> { where.not(answer: nil) } scope :without_answer, -> { where(answer: nil) } scope :on_site, -> { where(show_on_site: true) } scope :type_is, -> (condition) { where(faq_type: condition) } end end def to_s question end private def notify_user FaqMailer.notify_user(self).deliver if send_to_user end end end
Version data entries
42 entries across 42 versions & 2 rubygems