Sha256: d5d0fccc9b1701cd76c08924df7ec71fe4cb08e17df7817f684304ff593c97c9

Contents?: true

Size: 840 Bytes

Versions: 4

Compression:

Stored size: 840 Bytes

Contents

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

        include Enjoy::HtmlField

        included do

          field :name,          type: String, localize: Enjoy::Faq.configuration.localize

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

          enjoy_cms_html_field :excerpt,   type: String, localize: Enjoy::Faq.configuration.localize, default: ""
          enjoy_cms_html_field :content,   type: String, localize: Enjoy::Faq.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

4 entries across 4 versions & 1 rubygems

Version Path
enjoy_cms_faq-0.4.1 lib/enjoy/faq/models/mongoid/category.rb
enjoy_cms_faq-0.4.0.1 lib/enjoy/faq/models/mongoid/category.rb
enjoy_cms_faq-0.4.0 lib/enjoy/faq/models/mongoid/category.rb
enjoy_cms_faq-0.4.0.beta3 lib/enjoy/faq/models/mongoid/category.rb