Sha256: bf03fafff1e74b95f91d19c2f7b2ce90536b40f8651e28065eb7f735ad335913

Contents?: true

Size: 959 Bytes

Versions: 1

Compression:

Stored size: 959 Bytes

Contents

module Phcpress
  class Article::Post < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

    # Add Paper Trail
    has_paper_trail :class_name => 'Phcprss::PostVersions'

    # Image Upload Initialize
    mount_uploader :pstimage, Phcpress::PstimageUploader

    # Model Relationships
    has_many :connections, class_name: 'Phcpress::Modules::Connection', dependent: :destroy
    has_many :categories, class_name: 'Phcpress::Modules::Category', :through => :connections

    # Validation for Form Fields
    validates :psttitle,
      presence: true,
      length: { minimum: 3 }

      validates :psttext,
        presence: true,
        length: { minimum: 3 }

      validates :pststatus,
        presence: true

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

      # Define for Multiple Records
      def phcpress_posts_slug
        [
          [:psttitle]
        ]
      end

    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phcpress-10.0.0 app/models/phcpress/article/post.rb