I use Rails 3.0.20 and ruby 1.8.7 (2011-06-30 patchlevel 352)
Please suggest me the best plugin to generate guid.
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems. Sometimes it is referred to as a 'globally unique identifier'. These are a native column type in PostgreSQL. You can find more details on native Postgres types in the Rails Guides.
Ruby | Random uuid() function Random#uuid() : uuid() is a Random class method which checks returns a random v4 UUID (Universally Unique IDentifier). Syntax: Random.uuid() Parameter: Random values. Return: a random v4 UUID (Universally Unique IDentifier).
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.
The first thing I would suggest is that please upgrade your ruby and rails version.
A very good way of generating guid is SecureRandom, which is a ruby module. With easy usage.
require 'securerandom' guid = SecureRandom.hex(10) #or whatever value you want instead of 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With