Plugin to add automatic UUID support to AR
Ruby
Pull request Compare This branch is 1 commit ahead of gabrielg:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/thumble_monks
tasks
test
MIT-LICENSE
README.textile
Rakefile
init.rb

README.textile

active_record_uuid

Written by Gabriel Gironda

Download

Github: Page Clone

What is this?

This plugin adds auto-generated UUIDs to ActiveRecord models.

To add this capability to existing models:


  class AddUuidToInvites < ActiveRecord::Migration
    def self.up
      change_table :invites do |t|
        t.uuid
      end
    end

To set it up when creating new tables:


  class CreatePeople < ActiveRecord::Migration
    def self.up
      create_table :people do |t|
        t.string :name
        t.uuid
      end
    end

When your record is created, it’ll have a UUID, accessible via the ‘uuid’ attribute.

Todo

  • The generate_uuids! migration helper seems not to work, possibly because the uuid attribute is read-only.
  • Test cases failed to catch the above.
  • Addition of index in uuid migration is broken. See commit 697a2f7b02681b03ef1f7624f58ea19a622b3a32.

Copyright © 2007 Gabriel Gironda, released under the MIT license