diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 4747469cf..b48488fb8 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -164,16 +164,17 @@ class OrganizationsController < ApplicationController return end q = params[:search].nil? ? "" : "#{params[:search].strip}" - if params[:type] == "courses" || params[:type].nil? + @type = params[:type] + if @type == "courses" || @type.nil? @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") - elsif params[:type] == "students" + elsif @type == "students" @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") - elsif params[:type] == "resources" + elsif @type == "resources" @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") - elsif params[:type] == "famous" + elsif @type == "famous" @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") end diff --git a/app/views/organizations/_org_teachers_list.html.erb b/app/views/organizations/_org_teachers_list.html.erb index e24f53862..702675464 100644 --- a/app/views/organizations/_org_teachers_list.html.erb +++ b/app/views/organizations/_org_teachers_list.html.erb @@ -1,4 +1,4 @@ -<% @org_teachers.each do |org_teacher| %> +<% org_teachers.each do |org_teacher| %> <% school = School.where("id =?", org_teacher.school_id).first %>