FIX: rescue ActiveRecord::RecordInvalid in find_or_create_by_safe! (#6385)
AR uniqueness validation could raise ActiveRecord::RecordInvalid
This commit is contained in:
parent
02f582eca0
commit
f1cb431968
|
@ -15,7 +15,7 @@ class ActiveRecord::Base
|
|||
def self.find_or_create_by_safe!(hash)
|
||||
begin
|
||||
find_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 now
|
||||
find_or_create_by!(hash)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue