用户邮箱没注册时候显示用户邮箱方法封装

This commit is contained in:
huang 2016-12-08 09:36:01 +08:00
parent 8ba747e195
commit c84d17bd6a
1 changed files with 3 additions and 3 deletions

View File

@ -78,14 +78,14 @@ module ApplicationHelper
user.nil? ? mail : user.try(:show_name)
end
def link_to_user_mail(mail, options={})
def link_to_user_mail(mail, css_class)
user = User.find_by_mail(mail)
user = user.nil? ? mail : user
if user.is_a?(User)
name = user.show_name
link_to name, {:controller=> 'users', :action => 'show', id: user.id}, :class => user.css_classes
link_to name, {:controller=> 'users', :action => 'show', id: user.id}, :class => css_class, :target => "_blank"
else
h(user.to_s)
"<a class='#{css_class}'>#{h(user.to_s)}</a>".html_safe
end
end