Module: SubjModels::FaqModule

Includes:
TypesSupport::FaqTypes, ValuesChecker
Defined in:
lib/subj_models/faq.rb

Constant Summary

Constants included from TypesSupport::FaqTypes

TypesSupport::FaqTypes::FAQ, TypesSupport::FaqTypes::FAQ_DELIVERY, TypesSupport::FaqTypes::FAQ_PAYMENT, TypesSupport::FaqTypes::FAQ_TYPES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ValuesChecker

#check_string_for_int

Class Method Details

.included(including_class) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/subj_models/faq.rb', line 10

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

Instance Method Details

#to_sObject



34
35
36
# File 'lib/subj_models/faq.rb', line 34

def to_s
  question
end