What\'s the best way to generate unique codes to use as coupon codes?
Thanks.
If you don't want to waste comparing against the database (not a super expensive operation), you can guarantee that Time is always unique because it only occurs once
md5(Time.now.to_i.to_s+Time.now.usec.to_s)