at排序按照拼音来

This commit is contained in:
guange 2016-01-08 09:41:12 +08:00
parent 1b177a8498
commit 5ebfbc901a
1 changed files with 5 additions and 1 deletions

View File

@ -7,10 +7,14 @@ class AtController < ApplicationController
@logger = Logger.new(Rails.root.join('log', 'at.log').to_s)
users = find_at_users(params[:type], params[:id])
@users = users
@users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id } if users
@users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }.sort{|x,y| to_pinyin(x.show_name) <=> to_pinyin(y.show_name)} if users
end
private
def to_pinyin(s)
Pinyin.t(s).downcase
end
def find_at_users(type, id)
@logger.info("#{type}, #{id}")
case type