管理员界面无法搜索英文名称的课程
This commit is contained in:
parent
3f35b7f806
commit
4c45518913
|
@ -175,8 +175,10 @@ class AdminController < ApplicationController
|
|||
def courses
|
||||
@name = params[:name].to_s.strip.downcase
|
||||
if @name && @name != ""
|
||||
@courses = Course.select{ |course| course.teacher && ((course.teacher.show_name).include?(@name) || course.name.include?(@name))}
|
||||
@courses = @courses.sort{|x, y| y.created_at <=> x.created_at}
|
||||
all_user_ids = Course.all.map{|course| course.tea_id}
|
||||
user_str_ids = search_user_by_name all_user_ids, @name
|
||||
user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
|
||||
@courses = Course.where("tea_id in #{user_ids} or name like '%#{@name}%'").reorder("created_at desc")
|
||||
else
|
||||
@courses = Course.order('created_at desc')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue