views:

1074

answers:

2

How do I generate a globally unique ID in ruby (without rails/merb)?

+1  A: 

Google yields the following Ruby library:

http://raa.ruby-lang.org/project/ruby-guid/

Also, over at http://www.ruby-forum.com/topic/99262 they say you can install a gem (execute gem uuid on the command line to install it) and then do

gem 'uuid'
puts UUID.new

in your code to see a new UUID.

(Hint: I Googled for guid ruby)

Marc W
thx I saw that but it's super old, just looking for something active, like a recent gem?
viatropos
Nothing's wrong with an old library.
Ben Alpert
How about the uuid gem I added to my answer? Or is that the one you were referring to?
Marc W
UUIDTools works much better ...
Sam Saffron
+7  A: 

We use UUIDTools and have no problems with it.

Avdi
'uuidtools' works, even when the system has no MAC address. 'uuid' fails in this case.
gre