This reminds me of a wedding RSVP rails app I made two years ago. I did pretty much the same rsvp code generation approach but I found it helpful to store the RSVP codes to a database and use validates_uniqueness_of :rsvp_code to enforce the unlikely situation that no duplicate codes were generated.