Project

uuid_ids

0.0
No release in over 3 years
Low commit activity in last 3 years
A simple gem to auto generate UUIDs for the id field of models.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.2.13
>= 2.1.4
 Project Readme

UuidIds

A simple gem to make it easy to use UUIDs as the id for Rails models.

Gem Version Build Status Code Climate Coverage Status Dependency Status

Your table creation migration should look something like this:

    create_table :things, :id => false do |t|
      t.binary :id, :primary_key => true, :null => false
      t.timestamps
    end
    add_index :things, :id, :unique => true

binary type is your best bet as it will be put into schema.db correctly.

Then inside of your model just do this:

include UuidIds::ModelHelper

If you need to you can set the id outside of the model. If there is a collision (and you have a unique index) then an exception will be raised and it's up to your app to handle that. If you don't have a unique index and there is a collision you'll have two objects with the same id.

This project rocks and uses MIT-LICENSE.