From 4f5c9bb8d31c47aee7acef34390bafffd88a2d47 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 24 May 2019 12:06:58 +0800 Subject: [PATCH] DEV: Prefer `create!` over `create`. We want to know when stuff fails. --- app/models/user.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 7abdae8bf5b..8576a6a2287 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1029,7 +1029,7 @@ class User < ActiveRecord::Base api_key.regenerate!(created_by) api_key else - ApiKey.create(user: self, key: SecureRandom.hex(32), created_by: created_by) + ApiKey.create!(user: self, key: SecureRandom.hex(32), created_by: created_by) end end @@ -1131,7 +1131,7 @@ class User < ActiveRecord::Base end def create_user_profile - UserProfile.create(user_id: id) + UserProfile.create!(user_id: id) end def set_random_avatar @@ -1140,7 +1140,7 @@ class User < ActiveRecord::Base if urls.present? if upload = Upload.find_by(url: urls.sample) update_column(:uploaded_avatar_id, upload.id) - UserAvatar.create(user_id: id, custom_upload_id: upload.id) + UserAvatar.create!(user_id: id, custom_upload_id: upload.id) end end end @@ -1275,11 +1275,11 @@ class User < ActiveRecord::Base end def create_user_option - UserOption.create(user_id: id) + UserOption.create!(user_id: id) end def create_email_token - email_tokens.create(email: email) + email_tokens.create!(email: email) end def ensure_password_is_hashed