From 7f866a0b3af8a3a02b084ea6b208a494c1e4cadb Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 10 Dec 2015 10:00:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=A2=AB=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=90=8E=E4=B8=8D=E8=83=BD=E8=A2=AB=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index cef05de73..ee26d1d54 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -115,7 +115,7 @@ class Course < ActiveRecord::Base where(" LOWER(name) LIKE :p ", :p => pattern) end } - scope :indexable,lambda { where('is_public = 1') } + scope :indexable,lambda { where('is_public = 1 and is_delete = 0') } def self.search(query) __elasticsearch__.search( { @@ -400,12 +400,12 @@ class Course < ActiveRecord::Base # __elasticsearch__.delete_document # end def create_course_ealasticsearch_index - if self.is_public == 1 + if self.is_public == 1 and self.is_delete == 0 #公开 和 没有被删除的课程才被索引 self.__elasticsearch__.index_document end end def update_course_ealasticsearch_index - if self.is_public == 1 #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 + if self.is_public == 1 and self.is_delete == 0 #如果是初次更新成为公开或者恢复被删除的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 begin self.__elasticsearch__.update_document rescue => e