Yes, I plan on covering the refactoring soon. I wanted to get a bit more logic built in first. This upcoming episode, i'm doing something a little bit different. I go to meetups in my area and one thing that I've found is that people open have a fairly large disconnect from their production environment. So, I thought that a high level architectural overview could be beneficial to many.
I hadn't planned on covering testing on these since there are already some videos on the topic. https://www.driftingruby.com/episodes?query%5Bname%5D=&tag=test
However, I'll gladly add this episode in if the community would like to see them.
In this example where users may already exist, I would have a rake task which would populate the tokens for the users. Once the tokens have been generated, I would have another migration which would set the column to a `null: false`.
But I believe your confusion is valid as it should be `unless` instead of `if`.
`break if self.class.exists?(token: token)` would cause an endless loop while `break unless self.class.exists?(token: token)` would give the desired functionality.