Sha256: 27ef0474855290d9d357b3f83af7434fef0d3a269e0ab760d46b2baba0a95fcb
Contents?: true
Size: 604 Bytes
Versions: 5
Compression:
Stored size: 604 Bytes
Contents
# frozen_string_literal: true class Post < ApplicationRecord enum state: %i[available unavailable arriving] belongs_to :author, inverse_of: :posts, autosave: true has_one :author_profile, through: :author, source: :profile has_many :post_tags, inverse_of: :post, dependent: :destroy has_many :tags, through: :post_tags validates :title, allow_blank: false, presence: true scope :published, -> { where(published: true) } scope :recents, -> { where('created_at > ?', Date.today - 8.month) } def short_title title.truncate 10 end def upper_title title.upcase end end
Version data entries
5 entries across 5 versions & 1 rubygems