summaryrefslogtreecommitdiff
path: root/app/models/application_record.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/application_record.rb')
-rw-r--r--app/models/application_record.rb8
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