Sha256: 25b5adb782174f4c3c577924d743564e88702f7f41cfc05a1bb9c1fb71e5f0e9

Contents?: true

Size: 763 Bytes

Versions: 2

Compression:

Stored size: 763 Bytes

Contents

module Phcpress
  class Article::Category < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

    # Add Paper Trail
    has_paper_trail :class_name => 'Phcpress::CategoryVersions'

    # Relationships
    has_and_belongs_to_many :posts, class_name: 'Phcpress::Article::Post', :join_table => 'categories_posts', :dependent => :destroy
    belongs_to :user, class_name: 'Phcaccounts::User'

    # Validation for Form Fields
    validates :category_name,
      presence: true,
      uniqueness: true,
      length: { minimum: 3 }

    # Clean URL Define
    friendly_id :phcpress_category_slug, use: [:slugged, :finders]

    # Define for Multiple Records
    def phcpress_category_slug
      [
        [:category_name]
      ]
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phcpress-53.1.0 app/models/phcpress/article/category.rb
phcpress-53.0.0 app/models/phcpress/article/category.rb