I've watched a lot of Railscasts (thanks Ryan) and I need to recall some code I saw in one of them but my problem is I can't remember where to find it.
I can generate a 5 digit code using the code below and this is found in a method:
5.times.map { [*'A'..'Z'].sample }.join
but I need to be able to make sure that it's unique before saving. I remember Ryan using a loop of some sort in the model method to check that it is unique before saving.
Can you help?