From 4fb1a008cac888bee8efc6f6eeb56dbf464bba1a Mon Sep 17 00:00:00 2001 From: John Ma Date: Wed, 12 Sep 2018 17:03:01 -0400 Subject: [PATCH] Fixed #255 * * * --- app/models/user.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index f7d0be43..f71699a8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -92,7 +92,17 @@ class User < ApplicationRecord end def name_chunk - name[0...3].downcase + charset = ("a".."z").to_a - %w(b i l o s) + ("2".."9").to_a - %w(5 8) + chunk = name.parameterize[0...3] + if chunk.empty? + chunk + (0...3).map { charset.to_a[rand(charset.size)] }.join + elsif chunk.length == 1 + chunk + (0...2).map { charset.to_a[rand(charset.size)] }.join + elsif chunk.length == 2 + chunk + (0...1).map { charset.to_a[rand(charset.size)] }.join + else + chunk + end end def greenlight_account?