Sha256: c748eb04be5b9b4dc071c0f5a8e4c54a4b51b56e3bc9127b23a9a28873858bdb
Contents?: true
Size: 1.33 KB
Versions: 10
Compression:
Stored size: 1.33 KB
Contents
require_dependency "educode_sales/application_controller" module EducodeSales class HomeController < ApplicationController def index end def statistics end def no_permission end def search_users @users = User.where("concat(lastname, firstname) like :q OR login like :q OR phone like :q or mail like :q", q: "%#{params[:q]}%").limit(50) end def search if params[:type] == 'department' @data = Department.joins(:school).where("schools.name like :q", q: "%#{params[:q]}%").limit(50) unless @data.present? @data = Department.where("name like ?", "%#{params[:q]}%").limit(50) end elsif params[:type] == "school" data = School.where("name like ? ", "%#{params[:q]}%").limit(50) end end def search_teacher @data = Teacher.where("name like ? and is_key = false", "%#{params[:q]}%").limit(20) user_ids = @data.pluck(:user_id).compact.uniq @data += User.joins(:user_extension).where.not(id: user_ids).where("identity='teacher'", user_ids).where("lastname like ?", "%#{params[:q]}%").limit(50) end def search_edu_teacher @data = User.joins(:user_extension).where("identity='teacher'").where("concat(lastname, firstname) like :q OR phone like :q OR mail like :q", q: "%#{params[:q]}%").limit(50) end end end
Version data entries
10 entries across 10 versions & 1 rubygems