blob: d037aaba8d34a41996228272007f72ba375f8843 (
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
|
class Quote < ApplicationRecord
extend Enumerize
include Votable
acts_as_taggable
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
|