blob: 518d53bfcdf3de2ee9c134446e0f33e65c5329f6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
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
|