about summary refs log tree commit diff stats
path: root/app/models
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-10-21 00:25:50 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-10-21 00:25:50 -0400
commit96813a5e508a54257ef03be613a704f1f71af53d (patch)
treea50f5c8dc27304a3ca27366b6268a72804727e16 /app/models
parent2a7a19c93ee0e0d77e4e388d43f36a721c7ab715 (diff)
downloadthoughts-96813a5e508a54257ef03be613a704f1f71af53d.tar.gz
thoughts-96813a5e508a54257ef03be613a704f1f71af53d.tar.bz2
thoughts-96813a5e508a54257ef03be613a704f1f71af53d.zip
Added quotes database
Diffstat (limited to 'app/models')
-rw-r--r--app/models/quote.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/models/quote.rb b/app/models/quote.rb new file mode 100644 index 0000000..d037aab --- /dev/null +++ b/app/models/quote.rb
@@ -0,0 +1,33 @@
1class Quote < ApplicationRecord
2 extend Enumerize
3
4 include Votable
5
6 acts_as_taggable
7
8 validates :content, presence: true
9
10 enumerize :state,
11 in: [:published, :pending, :hidden],
12 default: :published,
13 predicates: true
14
15 scope :published, -> { where(state: :published) }
16 scope :pending, -> { where(state: :pending) }
17
18 def published_date
19 created_at.strftime("%B %d %Y at %I:%M:%S") + created_at.strftime(" %p").downcase + created_at.strftime(" %Z")
20 end
21
22 def has_extra?
23 has_notes? or has_tags?
24 end
25
26 def has_notes?
27 !notes.empty?
28 end
29
30 def has_tags?
31 !tags.empty?
32 end
33end