Skip to content

A platform for community discussion. Free, open, simple.

Shorten `User.suggest_name` further.

Guo Xiang Tanb3981ddc43a3
diff --git a/app/models/user.rb b/app/models/user.rb
index 568886d418d..1621ddee87f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -288,9 +288,7 @@ class User < ActiveRecord::Base
def self.suggest_name(string)
return "" if string.blank?
- local_part = string[/\A[^@]+/]
- suggestion = local_part.present? ? local_part : string[/[^@]+\z/]
- suggestion.tr(".", " ").titleize
+ (string[/\A[^@]+/].presence || string[/[^@]+\z/]).tr(".", " ").titleize
end
def self.find_by_username_or_email(username_or_email)