diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/models/application_record.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/models/application_record.rb')
-rw-r--r-- | app/models/application_record.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 9ec407a10a4..91b8bfedcbb 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -42,15 +42,15 @@ class ApplicationRecord < ActiveRecord::Base limit(count) end - def self.safe_find_or_create_by!(*args) - safe_find_or_create_by(*args).tap do |record| + def self.safe_find_or_create_by!(*args, &block) + safe_find_or_create_by(*args, &block).tap do |record| record.validate! unless record.persisted? end end - def self.safe_find_or_create_by(*args) + def self.safe_find_or_create_by(*args, &block) safe_ensure_unique(retries: 1) do - find_or_create_by(*args) + find_or_create_by(*args, &block) end end |