Sha256: 06523f2bea94fae7447c2122008b6d929a311aa5a13a0f788fc720134bf2cc64

Contents?: true

Size: 1.88 KB

Versions: 20

Compression:

Stored size: 1.88 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_article_categories_posts", :dependent => :destroy
      has_and_belongs_to_many :posts, class_name: "PhcdevworksPress::Review::Post", :join_table => "phcdevworks_press_review_categories_posts", :dependent => :destroy
      has_and_belongs_to_many :posts, class_name: "PhcdevworksPress::List::Post", :join_table => "phcdevworks_press_list_categories_posts", :dependent => :destroy
    end

    if defined?phcdevworks_portfolio
      has_and_belongs_to_many :posts, class_name: "PhcdevworksPortfolio::Project::Post", :join_table => "phcdevworks_portfolio_project_categories_posts", :dependent => :destroy
    end

    if defined?phcdevworks_tutorials
      has_and_belongs_to_many :posts, class_name: "PhcdevworksTutorials::Tutorial::Post", :join_table => "phcdevworks_tutorials_tutorial_categories_posts", :dependent => :destroy
      has_and_belongs_to_many :posts, class_name: "PhcdevworksTutorials::Command::Post", :join_table => "phcdevworks_tutorials_command_categories_posts", :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

20 entries across 20 versions & 1 rubygems

Version Path
phcdevworks_core_modules-7.2.2 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-7.2.1 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-7.2.0 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-7.1.4 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-7.1.3 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-7.1.2 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-7.1.1 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-7.1.0 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-7.0.0 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.5.0 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.4.0 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.3.0 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.2.1 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.2.0 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.1.0 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.0.4 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.0.3 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.0.2 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.0.1 app/models/phcdevworks_core_modules/post/category.rb
phcdevworks_core_modules-6.0.0 app/models/phcdevworks_core_modules/post/category.rb