class ApplicationFormReviewResult include Mongoid::Document include Mongoid::Timestamps PRESENTATION_TYPES = ["oral" , "poster"] field :sort_number , type: Integer , default: -1 field :abstract_number , type: String , default: "" field :presentation_type , type: String , default: "" #oral , poster belongs_to :application_form_signup_contribute before_save do self.sort_number = self.abstract_number.match(/[-]{0,1}\d+/)[0].to_i rescue -1 end after_save do ApplicationFormSignupContribute.where(:id=>self.application_form_signup_contribute_id).update_all(:sort_number=>self.sort_number,:abstract_number=>self.abstract_number,:presentation_type=>self.presentation_type) ApplicationFormSignup.where(:id.in=>ApplicationFormSignupContribute.where(:id=>self.application_form_signup_contribute_id).pluck(:application_form_signup_id)).update_all(:sort_number=>self.sort_number) end end