Sha256: a4d259806401bbf86c780df30f2cf4eebe586a714b46b90faf25e1d978e7e1c1

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

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 :tutorial_post_image

    # Relationships
    belongs_to :user, class_name: "PhcdevworksAccountsDevise"
    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_tutorial_categories_posts", :dependent => :destroy
    has_many :steps, class_name: "Tutorial::Step", :dependent => :destroy

    # Form Fields Validation
    validates :tutorial_post_title,
      presence: true

    validates :tutorial_post_text,
      presence: true

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

    def tutorial_post_nice_urls
      [:tutorial_post_title]
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phcdevworks_tutorials-13.0.2 app/models/phcdevworks_tutorials/tutorial/post.rb
phcdevworks_tutorials-13.0.1 app/models/phcdevworks_tutorials/tutorial/post.rb
phcdevworks_tutorials-13.0.0 app/models/phcdevworks_tutorials/tutorial/post.rb