Sha256: e683a76654556bba1d99b5372df6224a9ccbce5e698d53340dcf4216ff5b2e1d

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

module KnowledgeBase::Concerns::Models::Category
  extend ActiveSupport::Concern

  included do
    extend FriendlyId

    publishable on: :published_at

    friendly_id :title, use: :slugged

    belongs_to :category
    has_many :category_article_associations, -> { order 'position ASC' }
    has_many :articles, through: :category_article_associations

    accepts_nested_attributes_for :category_article_associations, allow_destroy: true

    scope :root, -> { where parent_id: nil }

    def to_s
      title
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
knowledge_base-0.2.0 lib/knowledge_base/concerns/models/category.rb