at排序按照拼音来
This commit is contained in:
parent
1b177a8498
commit
5ebfbc901a
|
@ -7,10 +7,14 @@ class AtController < ApplicationController
|
||||||
@logger = Logger.new(Rails.root.join('log', 'at.log').to_s)
|
@logger = Logger.new(Rails.root.join('log', 'at.log').to_s)
|
||||||
users = find_at_users(params[:type], params[:id])
|
users = find_at_users(params[:type], params[:id])
|
||||||
@users = users
|
@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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def to_pinyin(s)
|
||||||
|
Pinyin.t(s).downcase
|
||||||
|
end
|
||||||
|
|
||||||
def find_at_users(type, id)
|
def find_at_users(type, id)
|
||||||
@logger.info("#{type}, #{id}")
|
@logger.info("#{type}, #{id}")
|
||||||
case type
|
case type
|
||||||
|
|
Loading…
Reference in New Issue