asia_database/app/models/asia_patent.rb

21 lines
714 B
Ruby

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