Sha256: 3a8f39b21bdaafe0f7035b26ac2360dbae01f16ea458aee939c401a94e9e087e

Contents?: true

Size: 832 Bytes

Versions: 1

Compression:

Stored size: 832 Bytes

Contents

module Enjoy::Faq
  module Models
    module Mongoid
      module QuestionCategory
        extend ActiveSupport::Concern

        include Enjoy::HtmlField

        included do
          field :name,          type: String, localize: Enjoy.configuration.localize

          acts_as_nested_set
          scope :sorted, -> { order_by([:lft, :asc]) }

          enjoy_cms_html_field :excerpt,   type: String, localize: Enjoy.configuration.localize, default: ""
          enjoy_cms_html_field :content,   type: String, localize: Enjoy.configuration.localize, default: ""
        end

        def questions
          question_class.in(question_category_ids: self.id)
        end

        def all_questions
          question_class.any_in(question_category_ids: self.self_and_descendants.map(&:id))
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
enjoy_cms_faq-0.3.0.2 lib/enjoy/faq/models/mongoid/question_category.rb