Generating unique, hard-to-guess “coupon” codes

前端 未结 8 872
耶瑟儿~
耶瑟儿~ 2020-12-23 10:24

My Rails app needs to generate electronic coupons for users. Each coupon given should have a unique coupon code that can be redeemed on our system.

For example a cou

8条回答
  •  甜味超标
    2020-12-23 11:17

    You can e.g. use a random number and check if it was not generated before, by storing all valid codes in a database.

提交回复
热议问题