Sha256: 8ab9978813e53cabb8d5bbcbe178274d42297067e049e4f3932506d727e03e64

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

module PhcdevworksTutorials
  class Tutorial::Post < ApplicationRecord
  
    # Clean URL Initialize
    extend FriendlyId

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

    # Image Upload
    has_one_attached :post_image

    # Relationships
    belongs_to :user, class_name: "PhcdevworksAccounts::User"
    has_many :steps, class_name: "Tutorial::Step"
    has_and_belongs_to_many :categories, class_name: "PhcdevworksCoreModules::Modules::Category", :join_table => "phcdevworks_tutorials_categories_posts"

    # Form Fields Validation
    validates :post_title,
      presence: true

    validates :post_description,
      presence: true

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

    def phcdev_tutorial_post_nice_urls
      [:post_title]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phcdevworks_tutorials-7.0.0 app/models/phcdevworks_tutorials/tutorial/post.rb