A platform for community discussion. Free, open, simple.
FIX: rescue ActiveRecord::RecordInvalid in find_or_create_by_safe! (#6385)
Kyle Zhaof1cb4319686c
diff --git a/lib/freedom_patches/active_record_base.rb b/lib/freedom_patches/active_record_base.rbindex 4f71a4df380..39687ce2aa3 100644--- a/lib/freedom_patches/active_record_base.rb+++ b/lib/freedom_patches/active_record_base.rb@@ -15,7 +15,7 @@ class ActiveRecord::Basedef self.find_or_create_by_safe!(hash)beginfind_or_create_by!(hash)- rescue PG::UniqueViolation, ActiveRecord::RecordNotUnique+ rescue PG::UniqueViolation, ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid# try again cause another transaction could have passed by nowfind_or_create_by!(hash)end