A platform for community discussion. Free, open, simple.
Correctly handle exception
Sam6ee352510ac7
diff --git a/lib/freedom_patches/active_record_base.rb b/lib/freedom_patches/active_record_base.rbindex bcce2b39b97..4f71a4df380 100644--- a/lib/freedom_patches/active_record_base.rb+++ b/lib/freedom_patches/active_record_base.rb@@ -12,11 +12,10 @@ class ActiveRecord::Base# OR## find_by(hash) || create_or_find_by(hash) (if we are generally finding)- #def self.find_or_create_by_safe!(hash)beginfind_or_create_by!(hash)- rescue PG::UniqueViolation+ rescue PG::UniqueViolation, ActiveRecord::RecordNotUnique# try again cause another transaction could have passed by nowfind_or_create_by!(hash)end