wrapped uuid builder into begin/while block to prevent accidental uuid duplication

This commit is contained in:
acuppy
2012-11-04 11:44:08 -08:00
parent 9c0827dc4b
commit d4c39d59a3

View File

@@ -42,7 +42,9 @@ class Order < ActiveRecord::Base
end
def generate_uuid!
self.uuid = SecureRandom.hex(16)
begin
self.uuid = SecureRandom.hex(16)
end while Order.find_by_uuid(self.uuid).present?
end
# Implement these three methods to