Sha256: 438966e6d0695a1528e339598b1df88b832dc11d9648963080067409a1465bc7
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
require 'subj_models/concerns/comprising_external_id' module SubjModels module Faq 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_create :notify_manager 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 def faq_type=(value) super(check_string_for_int(value)) end private def notify_manager FaqMailer.notify_manager(self).deliver end def notify_user FaqMailer.notify_user(self).deliver if send_to_user end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
subj_models-0.4.1 | lib/subj_models/faq.rb |
subj_models-0.4 | lib/subj_models/faq.rb |