Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
22c37602db
|
@ -47,10 +47,14 @@ class SchoolController < ApplicationController
|
|||
options << "<option value = '#{p.province}' >#{p.province}</option>"
|
||||
end
|
||||
|
||||
# 查询已添加用户的学校
|
||||
schools_arr = UserExtensions.where("school_id IS NOT NULL").pluck(:school_id).uniq
|
||||
# 取id取学校名
|
||||
school = School.where(id: schools_arr).select("id, name")
|
||||
# 连接子表: 查询已添加用户的学校
|
||||
school = School.select("id, name").
|
||||
joins("RIGHT JOIN (
|
||||
SELECT DISTINCT school_id
|
||||
FROM #{UserExtensions.table_name}
|
||||
WHERE school_id IS NOT NULL) AS sids ON schools.id = sids.school_id").
|
||||
where("#{School.table_name}.id IS NOT NULL")
|
||||
|
||||
options_s = ""
|
||||
school.each do |s|
|
||||
|
|
Loading…
Reference in New Issue