AA said over 5 years ago on Refactoring Models :
Hello, Sorry for the question, but can you explain why you've constructed a loop with the `loop` statement for the token generation? If I'm not mistaken the `token` *value* of the hash parameter of the `exists?` method refers to `self.token` so basically the `token` attribute (i.e. column or method) of the current object being created (which is an in-memory object at that moment). I also assume that this value is `nil` since this column has no default value and `null` values are allowed. So the first time we presumably do not yet have any Users in the database with a `nil` token. Then the `break` instruction will not be executed, resulting to a second iteration for the loop, after a random token is being set for the in-memory object, right? So in the next iteration, we have a `token` value and we will `break` before setting another token if there are an existing user with that same token, am I still right? Then if not, we will continue like this again and again... And if so, we will end up with two users having the same token. Sorry for my bad English, but I hope my explanation makes sense... Can you explain what I misunderstood? Thank you. *(Thanks too for the videos!)*