diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 2cdb277be..8db852abd 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -25,7 +25,7 @@ module CoursesHelper # 获取tag匹配结果ID a_tags = [] # kc = keywords.to_a - Course.visible.where("is_excellent =?", 1).each do |ec| + Course.visible.where("is_excellent =? and is_public =?", 1, 1).each do |ec| if ec.tags.any?{|value| current_course.name.include?(value.to_s)} a_tags << ec.id end @@ -44,7 +44,7 @@ module CoursesHelper excellent_ids = a_courses.flatten.uniq.delete_if{|i| i == current_course.id} limit = 5 - excellent_ids.length.to_i sql = "SELECT distinct c.id FROM course_activities cs, courses c where cs.course_id = c.id - and c.is_excellent =1 and c.id != #{current_course.id} order by cs.updated_at desc;" + and c.is_excellent =1 and c.is_public = 1 and c.id != #{current_course.id} order by cs.updated_at desc;" default_ecourse_ids = Course.find_by_sql(sql).flatten # REDO:时间紧,待优化 default_ids =[]