diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/user.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index c6e754f..3063fc5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,7 +6,10 @@ class User < ActiveRecord::Base has_many :retweets has_one :account - scope :suggest_screen_name, ->(str) { where("screen_name LIKE ?", "#{str.gsub(/(_|%)/) {|x| "\\" + x }}%").order(screen_name: :asc) } + scope :suggest_screen_name, ->(str) { + escaped = str.gsub(/(_|%)/) {|x| "\\" + x } + where("screen_name LIKE ?", escaped + "%") + } class << self def find(*args) |