id转换成用户名

This commit is contained in:
huang 2016-07-25 09:47:14 +08:00
parent 48d5b89338
commit 43c6301223
2 changed files with 11 additions and 0 deletions

View File

@ -33,6 +33,12 @@ module ApplicationHelper
extend Forwardable extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
def user_path(resource, parameters = {})
if Fixnum === resource
resource = User.find(resource)
end
super
end
# def user_blogs_path(resource,parameters={}) # def user_blogs_path(resource,parameters={})
# super # super

View File

@ -311,6 +311,11 @@ class User < Principal
) )
end end
# id 转换成 登录名
def to_param
Fixnum === self.login ? id : login
end
# ====================================================================== # ======================================================================
def my_workplace def my_workplace
self.user_extensions.try(:occupation).to_s self.user_extensions.try(:occupation).to_s