Retrospring/app/helpers/user_helper.rb

15 lines
528 B
Ruby
Raw Normal View History

2014-11-02 08:57:37 -08:00
module UserHelper
2014-11-10 22:09:36 -08:00
# Decides what user name to show.
# @return [String] The user name
def user_screen_name(user, anonymous: false, url: true, link_only: false)
2014-11-11 09:09:28 -08:00
return APP_CONFIG['anonymous_name'] if user.nil? || anonymous
name = user.profile.display_name.blank? ? user.screen_name : user.profile.display_name
if url
link = show_user_profile_path(user.screen_name)
return link if link_only
return link_to(name, link, class: "#{"user--banned" if user.banned?}")
end
2015-06-09 09:05:35 -07:00
name.strip
2014-11-10 22:09:36 -08:00
end
2014-11-02 08:57:37 -08:00
end