Sha256: 44aff67428532e7129ae23a3bd03441982ae472d13a5050117c48af61e45f988

Contents?: true

Size: 1009 Bytes

Versions: 1

Compression:

Stored size: 1009 Bytes

Contents

module PhcdevworksTutorials
  class Command::Post < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

    # Paper Trail Initialize
    has_paper_trail :class_name => 'PhcdevworksTutorials::CommandPostVersions'

    # Image Upload
    has_one_attached :post_image

    # Relationships
    belongs_to :user, class_name: "PhcdevworksAccounts::User"
    belongs_to :optimization, class_name: "PhcdevworksCoreModules::Marketing::Optimization", optional: true
    has_and_belongs_to_many :categories, class_name: "PhcdevworksCoreModules::Post::Category", :join_table => "phcdevworks_tutorials_categories_commands"
    has_many :items, class_name: "Command::Item", :dependent => :destroy

    # Form Fields Validation
    validates :post_title,
      presence: true

    validates :post_description,
      presence: true

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

    def phcdev_command_post_nice_urls
      [:post_title]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phcdevworks_tutorials-8.0.1 app/models/phcdevworks_tutorials/command/post.rb