添加注释

This commit is contained in:
lizanle 2015-01-23 09:47:54 +08:00
parent 03ae5fdeac
commit 27fde6c641
1 changed files with 2 additions and 1 deletions

View File

@ -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, '<span class="search_results">\0</span>')}
log