diff --git a/db/migrate/20190820102040_change_exercise_1930_position.rb b/db/migrate/20190820102040_change_exercise_1930_position.rb index c46616e28..acf99b9e5 100644 --- a/db/migrate/20190820102040_change_exercise_1930_position.rb +++ b/db/migrate/20190820102040_change_exercise_1930_position.rb @@ -3,7 +3,7 @@ class ChangeExercise1930Position < ActiveRecord::Migration[5.2] exs = Exercise.all.includes(:exercise_questions) exs.each do |ex| ex_questions = ex&.exercise_questions&.select(:id,:question_number,:exercise_id)&.order("question_number ASC") #试卷的位置迁移 - if ex_questions.exists? + if ex_questions.present? ex_questions.each_with_index do |q,index| puts index q_num = index + 1 @@ -14,7 +14,7 @@ class ChangeExercise1930Position < ActiveRecord::Migration[5.2] end ex_q_bank = ex&.exercise_bank&.exercise_bank_questions&.select(:id,:question_number,:exercise_bank_id,:shixun_id)&.order("question_number ASC") #试卷的习题库位置迁移 - if ex_q_bank.exists? + if ex_q_bank.present? ex_q_bank.each_with_index do |q,index| puts index q_num_1 = index + 1