From 48b1d7ca159f58de7e24fe5afd511bd0b1654439 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 14:59:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/homework_common.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index d55973ed8..c0882ec6f 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -169,12 +169,8 @@ class HomeworkCommon < ApplicationRecord #删除时更新题库中的引用数 def update_homework_bank_quotes - old_banks = self.homework_bank - unless old_banks.blank? - old_banks.each do |bank| - bank.update_attributes(quotes: (bank.quotes - 1) > 0 ? (bank.quotes - 1) : 0, homework_common_id: nil) - end - end + old_bank = self.homework_bank + old_bank.update_attributes(quotes: (old_bank.quotes - 1) > 0 ? (old_bank.quotes - 1) : 0, homework_common_id: nil) end # 查重是否有新结果