Skip to content

A Rails plugin that makes assigning a UUID to your models a breeze.

License

Notifications You must be signed in to change notification settings

norbert/has_uuid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

has_uuid

has_uuid provides basic UUID assignment methods for ActiveRecord objects.

It depends on the uuidtools gem.

Installation

script/plugin install git://github.com/norbert/has_uuid.git

Usage

class Post < ActiveRecord::Base
  # automatically assign a UUID to the "uuid" column on create
  has_uuid
end

class Comment < ActiveRecord::Base
  # skip assignment on create
  has_uuid :auto => false
end

class User < ActiveRecord::Base
  # store the UUID in the "token" column, generate version 1 UUIDs
  has_uuid :column => :token, :generator => :timestamp
end

# assign a UUID if a valid one is not already present
@post.assign_uuid

# assign a UUID, replacing whatever is already there
@post.assign_uuid(:force => true)

# assign a UUID and save, replacing whatever is there
@post.assign_uuid!

# check if the current UUID is valid
@post.uuid_valid?

Credits

  • Norbert Crombach
  • Todd Eichel
  • Joerg Batterman

About

A Rails plugin that makes assigning a UUID to your models a breeze.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages