Application_Form/app/models/seminar_review_result.rb

17 lines
843 B
Ruby
Raw Normal View History

class SeminarReviewResult
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 :seminar_signup_contribute
before_save do
self.sort_number = self.abstract_number.match(/[-]{0,1}\d+/)[0].to_i rescue -1
end
after_save do
SeminarSignupContribute.where(:id=>self.seminar_signup_contribute_id).update_all(:sort_number=>self.sort_number,:abstract_number=>self.abstract_number,:presentation_type=>self.presentation_type)
SeminarSignup.where(:id.in=>SeminarSignupContribute.where(:id=>self.seminar_signup_contribute_id).pluck(:seminar_signup_id)).update_all(:sort_number=>self.sort_number)
end
end