From 3ba5d512cffcffe56936eddac162ef715eb761ad Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Mon, 16 Jan 2023 18:02:44 +0800 Subject: [PATCH] Fix bug. --- app/controllers/application_forms_controller.rb | 1 - app/models/application_form_signup.rb | 7 +++---- config/routes.rb | 1 + 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_forms_controller.rb b/app/controllers/application_forms_controller.rb index f2f1183..f14c24d 100644 --- a/app/controllers/application_forms_controller.rb +++ b/app/controllers/application_forms_controller.rb @@ -805,6 +805,5 @@ class ApplicationFormsController < ApplicationController template_data:{'application_form_id'=>application_form_id,'locale'=>I18n.locale,'extra_text'=> extra_text}.merge(extra_data), mail_lang: I18n.locale) end - mail.save end end diff --git a/app/models/application_form_signup.rb b/app/models/application_form_signup.rb index 780697f..7e61864 100644 --- a/app/models/application_form_signup.rb +++ b/app/models/application_form_signup.rb @@ -65,10 +65,9 @@ class ApplicationFormSignup self.process_stage = enable_idx.nil? ? 0 : (enable_idx + 1) end if self.serial_number.nil? - s = ApplicationFormSetting.first - s.last_serial_number += 1 - self.serial_number = s.last_serial_number - s.save(:validate=>false) + last_serial_number = ApplicationFormSetting.max(:last_serial_number).to_i + self.serial_number = last_serial_number + 1 + ApplicationFormSetting.update_all({"$inc"=>{"last_serial_number"=>1}}) end end after_destroy do diff --git a/config/routes.rb b/config/routes.rb index 7287682..3343e7b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,7 @@ Rails.application.routes.draw do locales = Site.first.in_use_locales rescue I18n.available_locales Thread.new do + ApplicationFormEmailSet.where(:field_name=>nil).destroy end scope "(:locale)", locale: Regexp.new(locales.join("|")) do namespace :admin do