Sha256: a76d23fa1c538d43f53582e7a73ee2ca7fed2f89c10665d974a5f6aaaf9e848e

Contents?: true

Size: 789 Bytes

Versions: 5

Compression:

Stored size: 789 Bytes

Contents

module PhcdevworksTutorials
  class Tutorial::Post < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

    # Image Upload
    has_one_attached :tutorial_post_image

    # Relationships
    has_and_belongs_to_many :categories, class_name: "Tutorial::Category", :join_table => "categories_posts", :dependent => :destroy
    has_many :steps, class_name: "Tutorial::Step"
    belongs_to :user, class_name: "PhcdevworksAccounts::User"

    # Form Fields Validation
    validates :tutorial_post_title,
      presence: true

    validates :tutorial_post_description,
      presence: true

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

    def phcdev_tutorials_post_nice_urls
      [:tutorial_post_title]
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
phcdevworks_tutorials-2.1.1 app/models/phcdevworks_tutorials/tutorial/post.rb
phcdevworks_tutorials-2.1.0 app/models/phcdevworks_tutorials/tutorial/post.rb
phcdevworks_tutorials-2.0.0 app/models/phcdevworks_tutorials/tutorial/post.rb
phcdevworks_tutorials-1.2.5 app/models/phcdevworks_tutorials/tutorial/post.rb
phcdevworks_tutorials-1.2.4 app/models/phcdevworks_tutorials/tutorial/post.rb