Sha256: 404147151182b55f4d926b307942af857ac23b7516a31797dd7b02d4a777e522

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

module PhcdevworksCoreModules
  class Post::Category < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

    # Paper Trail Initialize
    has_paper_trail :class_name => "PhcdevworksCoreModules::PostCategoryVersions"

    # Relationships for Local
    belongs_to :user, class_name: "PhcdevworksAccounts::User"
    belongs_to :optimization, class_name: "PhcdevworksCoreModules::Marketing::Optimization", optional: true

    # Relationships for PHCDevworks Plugins
    if defined?phcdevworks_press
      has_and_belongs_to_many :posts, class_name: "PhcdevworksPress::Article::Post", :join_table => "phcdevworks_press_categories_posts", :dependent => :destroy
    end
    if defined?phcdevworks_portfolio
      has_and_belongs_to_many :posts, class_name: "PhcdevworksPortfolio::Project::Post", :join_table => "phcdevworks_portfolio_categories_posts", :dependent => :destroy
    end
    if defined?phcdevworks_tutorials
      has_and_belongs_to_many :posts, class_name: "PhcdevworksTutorials::Tutorial::Post", :join_table => "phcdevworks_tutorials_categories_posts", :dependent => :destroy
      has_and_belongs_to_many :posts, class_name: "PhcdevworksTutorials::Command::Post", :join_table => "phcdevworks_tutorials_categories_commands", :dependent => :destroy
    end

    # Form Fields Validation
    validates :post_category_name,
      presence: true,
      uniqueness: true

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

    def post_category_nice_urls
      [:post_category_name]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phcdevworks_core_modules-5.0.0 app/models/phcdevworks_core_modules/post/category.rb