|
|
|
@ -84,10 +84,10 @@ class CoursesController < ApplicationController
|
|
|
|
|
#@courses = @courses.where("name like ?", "%#{params[:search]}%").or(@courses.where(tea_id: user_ids)).or(@courses.where(id: course_ids))
|
|
|
|
|
# 6:21 daiao
|
|
|
|
|
sql = %Q{
|
|
|
|
|
(course_members.role in (1,2,3) and CONCAT(users.lastname, users.firstname) like :keyword) or courses.name like :keyword
|
|
|
|
|
(course_members.role in(1,2,3) and CONCAT(users.lastname, users.firstname) like :keyword) or courses.name like :keyword
|
|
|
|
|
or schools.name like :keyword
|
|
|
|
|
}
|
|
|
|
|
@courses = @courses.includes(course_members: [user: [user_extension: :school]]).where("#{sql}", keyword: "%#{params[:search]}%")
|
|
|
|
|
@courses = @courses.joins(course_members: [user: [user_extension: :school]]).where("#{sql}", keyword: "%#{params[:search]}%")
|
|
|
|
|
end
|
|
|
|
|
@courses_count = @courses.size
|
|
|
|
|
|
|
|
|
|