Sha256: 55655deb762a76e33f37fae45cde5f6526a295f862505e735c2bbec2405c5080

Contents?: true

Size: 572 Bytes

Versions: 1

Compression:

Stored size: 572 Bytes

Contents

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

  included do
    extend FriendlyId

    publishable on: :published_at

    friendly_id :title, use: :slugged

    has_many :category_article_associations
    has_many :categories, through: :category_article_associations
    has_many :sections, -> { order 'position ASC' }, as: :container,
      dependent: :destroy

    accepts_nested_attributes_for :category_article_associations
    accepts_nested_attributes_for :sections, allow_destroy: true

    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/article.rb