David Kimura PRO said almost 6 years ago on Refactoring Models :
If by chance the token already exists then it will not generate the token. This probably would rarely happen on a small app with `SecureRandom.hex`, but on a larger table could be a concern. Another way to write it could be something like ``` def generate_token begin self.token = SecureRandom.hex end while self.class.exists?(token: token) end ```