You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first requires the gem base32, but the latter uses only built-in libraries (require 'base64' and require 'securerandom'). This seems better than depending on the coupon gem, especially since we don't use any of the "features" of the coupon gem.
As per Elijah's comments below:
Remove the coupon gem and instead generate codes with something like this:
Base32.encode(SecureRandom.random_bytes).downcase[0..7]
or
Base64.encode64(SecureRandom.random_bytes).downcase.gsub(/[0oi1+_/]/,'')[0..7]
The first requires the gem base32, but the latter uses only built-in libraries (require 'base64' and require 'securerandom'). This seems better than depending on the coupon gem, especially since we don't use any of the "features" of the coupon gem.
[...]
Base64.encode64(SecureRandom.random_bytes).downcase.gsub(/[0oil1+_/]/,'')[0..7].scan(/..../).join('-')
=> "myk9-qjdb"
We may want the length configurable in the future, but I think anything longer than 8 characters is unnecessary.
The text was updated successfully, but these errors were encountered: