class Quote < ApplicationRecord extend Enumerize include Votable acts_as_taggable has_one_attached :audio validates :content, presence: true enumerize :state, in: [:published, :pending, :hidden], default: :published, predicates: true scope :published, -> { where(state: :published) } scope :pending, -> { where(state: :pending) } def published_date created_at.strftime("%B %d %Y at %I:%M:%S") + created_at.strftime(" %p").downcase + created_at.strftime(" %Z") end def has_extra? has_notes? or has_tags? end def has_notes? !notes.empty? end def has_tags? !tags.empty? end end