From 27fde6c641601f0cc013a1a4cc02f7867248a94d Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 23 Jan 2015 09:47:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/system_log_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/helpers/system_log_helper.rb b/app/helpers/system_log_helper.rb index 1125904c8..53cf2038b 100644 --- a/app/helpers/system_log_helper.rb +++ b/app/helpers/system_log_helper.rb @@ -12,12 +12,13 @@ module SystemLogHelper if keywords && !keywords.strip.blank? # 把keywords转化成正则表达式数组 keywords = keywords.strip.split(/\s+/).collect! {|w| Regexp.new(w, 'i')} - # 一条记录应该匹配每个关键字 + # 一条记录应该匹配每个关键字 log =~ r 是对log记录进行判断是否符合r的正则表达式 logs = logs.find_all do |log| keywords.all? { |r| log =~ r } end #用Kaminari分页 logs = Kaminari.paginate_array(logs).page(page).per(per).collect! {|log| parse(log)} + #将分页后的记录的搜索结果添加样式,样式中的\0是给给r占位置的。 logs.collect! do |log| keywords.each { |r| log.gsub!(r, '\0')} log