diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index f128746ef..cbf4fee2b 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -24,11 +24,11 @@ class SubjectsController < ApplicationController # ζœ€ηƒ­ζŽ’εΊ if reorder == "myshixun_count" if current_laboratory.main_site? - not_subject_ids = Subject.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id}") + not_subject_ids = Subject.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id}").pluck(:id) not_subject_ids = not_subject_ids.length > 0 ? "(" + not_subject_ids.join(",") + ")" : "(-1)" laboratory_join = " AND subjects.id not in #{not_subject_ids} " else - subject_ids = Subject.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id }) + subject_ids = Subject.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id }).pluck(:id) subject_ids = subject_ids.length > 0 ? "(" + subject_ids.join(",") + ")" : "(-1)" laboratory_join = " AND subjects.id in #{subject_ids} " end