Rails 4 has native support for the type UUID (Universally Unique Identifier) in Postgres. In this Div Bit I will describe how you can use it for generating UUIDs without doing it manually in your Rails code. First you need to enable the Postgres extension ‘uuid-ossp’: class CreateUuidPsqlExtension < ActiveRecord::Migration def self.up execute "CREATE EXTENSION \"uuid-ossp\";" end def self.down exe