class Cancerpredictrecord include Mongoid::Document include Mongoid::Timestamps include OrbitModel::Status include OrbitModel::Impression # encoding: utf-8 include OrbitTag::Taggable include OrbitCategory::Categorizable field :title ,type:String ,default:"" field :submit_time ,type:String ,default:"" field :result , type:Hash , default:{} field :names , type:Hash , default:{} field :values , type:Hash , default:{} field :submit_numbers , type:Fixnum , default: 1 scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])} scope :is_approved, ->{where(:approved => true)} before_save :set_submit_times def set_submit_times self.submit_time = Cancerpredictrecord.where(:title=> "cancerpredict").length + 1 end end