Jeffrey Soong said about 4 years ago on ActiveRecord Callbacks :
is there any benefit to writing the generate_token with begin/end over something like that?

def generate_token
   while self.class.exists?(token: token)
     self.token = SecureRandom.hex(8)
   end
end