class Post < ApplicationRecord
  self.table_name_prefix = "st_"
  validates :title, presence: true

  belongs_to :user
  belongs_to :post_category
  has_one_attached :cover do |attachable|
    attachable.variant :thumb, resize_to_fill: [150, nil]
  end

  scope :published, -> { where(is_draft: false) }

  def published?
    !is_draft?
  end
end
