diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 3bb1b262..84461ff0 100755 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -159,11 +159,11 @@ class ExerciseController < ApplicationController end if search.blank? - @shixuns = Shixun.where("shixuns.status = 2 and challenges_count = 1 and shixuns.id not in (#{none_shixun_ids.join(",")})"). + @shixuns = Shixun.where("shixuns.status = 2 and challenges_count = 1 and shixuns.id not in (#{none_shixun_ids.join(",")})").uniq. select{|shixun| shixun.challenges.where(:st => 1).count == 0} else - @shixuns = Shixun.joins(challenges: :challenge_tags).where("shixuns.status = 2 and challenges_count = 1 and shixuns.id not in (#{none_shixun_ids.join(",")})"). + @shixuns = Shixun.joins(challenges: :challenge_tags).where("shixuns.status = 2 and challenges_count = 1 and shixuns.id not in (#{none_shixun_ids.join(",")})").uniq. where("shixuns.name like ? or challenge_tags.name like ?", "%#{search}%", "%#{search}%").select{|shixun| shixun.challenges.where(:st => 1).count == 0} end diff --git a/app/views/exercise/_new_shixun_exercise_list.html.erb b/app/views/exercise/_new_shixun_exercise_list.html.erb index 2b611f13..8de7acfb 100755 --- a/app/views/exercise/_new_shixun_exercise_list.html.erb +++ b/app/views/exercise/_new_shixun_exercise_list.html.erb @@ -61,7 +61,7 @@ if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) { msg_list_loading = true; - $.getJSON("<%= choose_shixuns_exercise_path(@exercise) %>?page="+page, function(json) { + $.getJSON("<%= choose_shixuns_exercise_path(@exercise) %>?page="+page+"&search="+$("input[name='search']").val(), function(json) { if (json) { msg_list_loading = false; var str = "";