diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index b3e317e4b..7857f2ec6 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -69,7 +69,8 @@ class SubjectsController < ApplicationController else @subjects = @subjects[offset, limit] subject_ids = @subjects.pluck(:id) - @subjects = Subject.where(id: subject_ids).order("field(id,#{subject_ids.join(',')})").includes(:shixuns, :repertoire) + order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1 + @subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, :repertoire) end end