-
Notifications
You must be signed in to change notification settings - Fork 13
User Handles
Dave Kaplan edited this page Jun 9, 2018
·
3 revisions
Handles will come from the Network, however this was a quick script to generate unique handles for all users.
User.find_each do |u|
if u.handle.blank?
if u.pending?
h = u.email.split('@').first
else
h = u.name.downcase.gsub(' ', '')
end
new_h = h
existing = User.find_by_handle(h)
i = 0
while existing do
i += 1
new_h = "#{h}-#{i}"
existing = User.find_by_handle(new_h)
end
u.update(handle: new_h)
end
end