From e3fcd3fa80fa8d4179d4fbd600c1b94558061167 Mon Sep 17 00:00:00 2001 From: Andrew Bezzub Date: Mon, 9 Jun 2014 23:07:16 -0700 Subject: [PATCH] update import script to save bio to UserProfile --- script/import_scripts/base.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/script/import_scripts/base.rb b/script/import_scripts/base.rb index f6bdd3f75..1904d8752 100644 --- a/script/import_scripts/base.rb +++ b/script/import_scripts/base.rb @@ -140,6 +140,7 @@ class ImportScripts::Base existing = User.where(email: opts[:email].downcase, username: opts[:username]).first return existing if existing and existing.custom_fields["import_id"].to_i == import_id.to_i + bio_raw = opts.delete(:bio_raw) opts[:name] = User.suggest_name(opts[:name]) if opts[:name] opts[:username] = UserNameSuggester.suggest((opts[:username].present? ? opts[:username] : nil) || opts[:name] || opts[:email]) opts[:email] = opts[:email].downcase @@ -150,7 +151,13 @@ class ImportScripts::Base u.custom_fields["import_username"] = opts[:username] if opts[:username].present? begin - u.save! + User.transaction do + u.save! + if bio_raw.present? + u.user_profile.bio_raw = bio_raw + u.user_profile.save! + end + end rescue # try based on email existing = User.find_by(email: opts[:email].downcase)