Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /app/models/application_record.rb
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/models/application_record.rb')
-rw-r--r--app/models/application_record.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
index 1bbace791ed..5e5bc00458e 100644
--- a/app/models/application_record.rb
+++ b/app/models/application_record.rb
@@ -66,6 +66,12 @@ class ApplicationRecord < ActiveRecord::Base
end
end
+ def create_or_load_association(association_name)
+ association(association_name).create unless association(association_name).loaded?
+ rescue ActiveRecord::RecordNotUnique, PG::UniqueViolation
+ association(association_name).reader
+ end
+
def self.underscore
Gitlab::SafeRequestStore.fetch("model:#{self}:underscore") { self.to_s.underscore }
end
@@ -80,4 +86,4 @@ class ApplicationRecord < ActiveRecord::Base
end
end
-ApplicationRecord.prepend_if_ee('EE::ApplicationRecordHelpers')
+ApplicationRecord.prepend_mod_with('ApplicationRecordHelpers')