asia_database/app/models/asia_tec_transfer.rb

20 lines
627 B
Ruby

class AsiaTecTransfer
include Mongoid::Document
include Mongoid::Timestamps
include Slug
field :tech_transfer_name, :type => String, :default => "", :localize => true, :as => :slug_title
field :start_date, :type => Date
field :end_date, :type => Date
field :receiving_unit, :type => String, :default => "", :localize => true
field :rss2_id
belongs_to :asia_teacher, index: true
scope :sort_order, ->{order({start_date: -1})}
index({start_date: -1}, { unique: false, background: true })
def period
if self.start_date.nil? && self.end_date.nil?
""
else
"#{self.start_date} ~ #{self.end_date}"
end
end
end