Skip to content

Instantly share code, notes, and snippets.

@ktravers
Last active July 12, 2018 03:00
Show Gist options
  • Save ktravers/0f2809e0cf22ee3c43bcb451e49f8b12 to your computer and use it in GitHub Desktop.
Save ktravers/0f2809e0cf22ee3c43bcb451e49f8b12 to your computer and use it in GitHub Desktop.
def display_name(user)
if user.first_name.length > 0
if user.last_name.length > 0
"#{user.first_name} #{user.last_name}".strip
else
"#{user.first_name}".strip
end
elsif user.username.length > 0
user.username
else
'New User'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment