From 7e45af8698d9ad3341b866024e17eb8690b2c69a Mon Sep 17 00:00:00 2001 From: nemesisdesign Date: Mon, 27 Apr 2015 14:39:39 +0200 Subject: [PATCH] Avoid possible exceptions in CleanUnusedMobilePhones data migration --- db/migrate/20150422124519_clean_unused_mobile_phones.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/migrate/20150422124519_clean_unused_mobile_phones.rb b/db/migrate/20150422124519_clean_unused_mobile_phones.rb index 9e241f5..a7e0c26 100644 --- a/db/migrate/20150422124519_clean_unused_mobile_phones.rb +++ b/db/migrate/20150422124519_clean_unused_mobile_phones.rb @@ -3,7 +3,11 @@ def self.up # this will run the before_validation check and clean up # users which have a mobile_suffix and mobile_prefix filled even if not needed Account.all.each do |user| - user.save! + if user.valid? + user.save + else + puts "Problems with user: #{user.username}, id: #{user.id},\nerrors: #{user.errors}\n\n" + end end end