mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 08:03:44 +08:00
DEV: Prefer create!
over create
.
We want to know when stuff fails.
This commit is contained in:
parent
9ce06d53d1
commit
4f5c9bb8d3
|
@ -1029,7 +1029,7 @@ class User < ActiveRecord::Base
|
||||||
api_key.regenerate!(created_by)
|
api_key.regenerate!(created_by)
|
||||||
api_key
|
api_key
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1131,7 +1131,7 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_user_profile
|
def create_user_profile
|
||||||
UserProfile.create(user_id: id)
|
UserProfile.create!(user_id: id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_random_avatar
|
def set_random_avatar
|
||||||
|
@ -1140,7 +1140,7 @@ class User < ActiveRecord::Base
|
||||||
if urls.present?
|
if urls.present?
|
||||||
if upload = Upload.find_by(url: urls.sample)
|
if upload = Upload.find_by(url: urls.sample)
|
||||||
update_column(:uploaded_avatar_id, upload.id)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -1275,11 +1275,11 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_user_option
|
def create_user_option
|
||||||
UserOption.create(user_id: id)
|
UserOption.create!(user_id: id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_email_token
|
def create_email_token
|
||||||
email_tokens.create(email: email)
|
email_tokens.create!(email: email)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_password_is_hashed
|
def ensure_password_is_hashed
|
||||||
|
|
Loading…
Reference in New Issue
Block a user