asia_database/app/models/asia_exhibition.rb

20 lines
710 B
Ruby
Raw Normal View History

2023-05-26 14:17:05 +00:00
class AsiaExhibition
include Mongoid::Document
include Mongoid::Timestamps
include Slug
field :exhibition_name, :type => String, :default => "", :localize => true, :as => :slug_title
field :exhibition_start_date, :type => Date
field :exhibition_end_date, :type => Date
field :host, :type => String, :default => "", :localize => true
field :rss2_id
belongs_to :asia_teacher, index: true
scope :sort_order, ->{order({exhibition_start_date: -1})}
index({exhibition_start_date: -1}, { unique: false, background: true })
def exhibition_date
if self.exhibition_start_date.nil? && self.exhibition_end_date.nil?
""
else
"#{self.exhibition_start_date} ~ #{self.exhibition_end_date}"
end
end
end