Browse Source

fixed 搜索用户时过虑表情字符

pull/342/head
xxq250 3 years ago
parent
commit
701d5dea40
2 changed files with 2 additions and 2 deletions
  1. +1
    -1
      app/models/owner.rb
  2. +1
    -1
      app/models/user.rb

+ 1
- 1
app/models/owner.rb View File

@@ -70,7 +70,7 @@ class Owner < ApplicationRecord

scope :like, lambda { |keywords|
# 表情处理
keywords = keywords.each_char.select { |c| c.bytes.first < 240 }.join('')
keywords = keywords.to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
sql = "CONCAT(lastname, firstname) LIKE :search OR nickname LIKE :search OR login LIKE :search "
where(sql, :search => "%#{keywords.strip}%") unless keywords.blank?
}


+ 1
- 1
app/models/user.rb View File

@@ -186,7 +186,7 @@ class User < Owner
scope :active, lambda { where(status: [STATUS_ACTIVE, STATUS_EDIT_INFO]) }
scope :like, lambda { |keywords|
# 表情处理
keywords = keywords.each_char.select { |c| c.bytes.first < 240 }.join('')
keywords = keywords.to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
sql = "CONCAT(lastname, firstname) LIKE :search OR nickname LIKE :search OR login LIKE :search OR mail LIKE :search OR nickname LIKE :search"
where(sql, :search => "%#{keywords.strip}%") unless keywords.blank?
}


Loading…
Cancel
Save