Skip to content

gabrielg/active_record_uuid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Plugin to add automatic UUID support to AR

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages