From 6c6d406e6390dd1c7ea0921fae419379ce03758f Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 29 Oct 2015 16:47:27 -0400 Subject: [PATCH] Small fixes to import base. --- script/import_scripts/base.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/script/import_scripts/base.rb b/script/import_scripts/base.rb index 18da1fd7aa5..ea98e73cb02 100644 --- a/script/import_scripts/base.rb +++ b/script/import_scripts/base.rb @@ -246,7 +246,7 @@ class ImportScripts::Base failed += 1 puts "Failed to create user id: #{import_id}, username: #{new_user.username}, email: #{new_user.email}" puts "user errors: #{new_user.errors.full_messages}" - puts "user_profile errors: #{new_user.user_profiler.errors.full_messages}" + puts "user_profile errors: #{new_user.user_profile.errors.full_messages}" if new_user.user_profile.present? && new_user.user_profile.errors.present? end else failed += 1 @@ -273,6 +273,10 @@ class ImportScripts::Base location = opts.delete(:location) avatar_url = opts.delete(:avatar_url) + # Allow the || operations to work with empty strings '' + opts[:name] = nil if opts[:name].blank? + opts[:username] = nil if opts[:username].blank? + opts[:name] = User.suggest_name(opts[:email]) unless opts[:name] if opts[:username].blank? || opts[:username].length < User.username_length.begin || @@ -317,7 +321,7 @@ class ImportScripts::Base u = existing end else - puts "Error on record: #{opts}" + puts "Error on record: #{opts.inspect}" raise e end end