blob: b1d25b431d856b9f4dd8bd6f559b4be587024bee (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
|
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 title
"Quote \##{id}"
end
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
def self.ransackable_attributes(auth_object = nil)
["content", "notes"]
end
def self.ransackable_associations(auth_object = nil)
[]
end
end
|