Shortcut and return on duplicate record error.

This commit is contained in:
Andreas Brandl 2018-03-06 12:45:28 +01:00
parent 8e668076a9
commit 9f7767079e
1 changed files with 3 additions and 3 deletions

View File

@ -30,9 +30,9 @@ class UserInteractedProject < ActiveRecord::Base
rescue ActiveRecord::RecordNotUnique
# Note, above queries are not atomic and prone
# to race conditions (similar like #find_or_create!).
# We retry and make sure the outer transaction (if any)
# is not aborted because of this.
retry
# In the case where we hit this, the record we want
# already exists - shortcut and return.
true
end
end
end