I need to generate uuid for my rails application. What are the options(gems) I have?

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

I would suggest using PostgreSQL and using the uuid column built in, it autogenerates UUID based on type you create the column.

Example in Rails 3 migration

execute <<-SQL CREATE TABLE some_items (id uuid PRIMARY KEY DEFAULT uuid_generate_v1()); SQL

Might be a better way to do this in Rails 4.