From 96813a5e508a54257ef03be613a704f1f71af53d Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 21 Oct 2023 00:25:50 -0400 Subject: Added quotes database --- app/models/quote.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/models/quote.rb (limited to 'app/models') 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 @@ +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 -- cgit 1.4.1