Generating Guids in Ruby

后端 未结 10 1871
南笙
南笙 2020-11-27 10:53

I have problem that is really easily solved with Guids.

In particular, for a password reset workflow, I would like to send a Guid token to a user\'s email and have

10条回答
  •  旧时难觅i
    2020-11-27 11:30

    As of Ruby 1.9, uuid generation is built-in. Use the SecureRandom.uuid function.

    For example:

    require 'securerandom'
    SecureRandom.uuid # => "96b0a57c-d9ae-453f-b56f-3b154eb10cda"
    

提交回复
热议问题