Sha256: 59e946bd5dd58440f50c1b80358fef49004e3564aa9759ff9362eb35086c8359

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

module PhcdevworksCoreModules
  class Modules::Category < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

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

    # Relationships
    belongs_to :user, class_name: "PhcdevworksAccounts::User"
    has_and_belongs_to_many :posts, class_name: "PhcdevworksPress::Article::Post", :join_table => "phcdevworks_press_categories_posts", :dependent => :destroy
    has_and_belongs_to_many :posts, class_name: "PhcdevworksPortfolio::Project::Post", :join_table => "phcdevworks_portfolio_categories_posts", :dependent => :destroy
    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

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

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

    def phcdev_core_category_nice_urls
      [:category_name]
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phcdevworks_core_modules-1.0.0 app/models/phcdevworks_core_modules/modules/category.rb
phcdevworks_core_modules-0.4.0 app/models/phcdevworks_core_modules/modules/category.rb