UUID extension for ActiveRecord
Ruby
Latest commit c4489dc Sep 8, 2014 Gabriel Naiman Added rake development dependency
Permalink
Failed to load latest commit information.
lib Remove rails dependency. Sep 8, 2014
spec Fix for JRuby tests. Sep 8, 2014
.gitignore First commit Oct 6, 2012
.ruby-gemset
.travis.yml Fix for JRuby tests. Sep 8, 2014
Gemfile First commit Oct 6, 2012
README.md Remove rails dependency. Sep 8, 2014
Rakefile Fix for JRuby tests. Sep 8, 2014
activerecord_uuid.gemspec Added rake development dependency Sep 8, 2014

README.md

ActiveRecordUUID

Gem Version Build Status

UUID extension for ActiveRecord

Installation

Add this line to your application's Gemfile:

gem 'activerecord_uuid'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activerecord_uuid

Usage

Migrations

Define attribute as UUID

class CreateCountries < ActiveRecord::Migration
  def change
    create_table :countries do |t|
      t.uuid :key
    end
  end
end

Define primary key as UUID

class CreateLanguages < ActiveRecord::Migration
  def change
    create_table :languages do |t|
      t.uuid :id, primary_key: true
    end
  end
end

Models

For automatic generation of UUID before creation

class Country < ActiveRecord::Base
  attr_uuid :key
end

For change primary key to UUID

class Language < ActiveRecord::Base
  pk_uuid
end

Manually creation of UUIDs

ActiveRecordUUID.random

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request