我需要为Rails应用程序生成uuid.我有哪些选择(宝石)? [英] I need to generate uuid for my rails application. What are the options(gems) I have?

查看:175
本文介绍了我需要为Rails应用程序生成uuid.我有哪些选择(宝石)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 Rails 3.0.20和 红宝石1.8.7(2011-06-30补丁程序352)

I use Rails 3.0.20 and ruby 1.8.7 (2011-06-30 patchlevel 352)

请向我建议最好的可生成guid的插件.

Please suggest me the best plugin to generate guid.

推荐答案

有很多选项,我建议不要添加其他依赖项,而应使用内置的SecureRandom:

There are plenty of options, I recommend not to add additional dependencies and use SecureRandom which is builtin:

SecureRandom.uuid #=> "1ca71cd6-08c4-4855-9381-2f41aeffe59c"

此处查看其他可能的格式.

See other possible formats here.

这篇关于我需要为Rails应用程序生成uuid.我有哪些选择(宝石)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆