From a45db2488eca18aa8faf942b8b64ec6f4408280b Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Mon, 16 Jan 2023 17:57:07 +0800 Subject: [PATCH] Fix bug. --- app/models/seminar_signup.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/models/seminar_signup.rb b/app/models/seminar_signup.rb index c73aef2..91aef93 100644 --- a/app/models/seminar_signup.rb +++ b/app/models/seminar_signup.rb @@ -51,10 +51,9 @@ class SeminarSignup [l, (tmp ? tmp : unit)] end.to_h if self.serial_number.nil? - s = SeminarMain.find(self.seminar_main) - s.last_serial_number += 1 - self.serial_number = s.last_serial_number - s.save(:validate=>false) + last_serial_number = SeminarMain.where(:id=>self.seminar_main_id).max(:last_serial_number).to_i + self.serial_number = last_serial_number + 1 + SeminarMain.where(:id=>self.seminar_main_id).update_all({"$inc"=>{"last_serial_number"=>1}}) end end after_destroy do