class Ecs::EcMajorsController < Ecs::BaseController def index school_major_subquery = current_school.ec_major_schools.select(:ec_major_id) #学校已选择的专业 ec_majors = EcMajor.where.not(id: school_major_subquery) if params[:search].present? ec_majors = ec_majors.search_name_or_code(params[:search]) end @count = ec_majors.count @ec_majors = paginate(ec_majors) end private def current_school @_current_school ||= School.find(params[:school_id]) end end