Skip to content

Instantly share code, notes, and snippets.

@chrislloyd
Created August 13, 2012 20:51
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chrislloyd/3344006 to your computer and use it in GitHub Desktop.
Save chrislloyd/3344006 to your computer and use it in GitHub Desktop.
create_table :users, id: false do |t|
t.uuid :id, primary: true, null: false
# ...
end
require 'uuid'
module UUIDPrimaryKey
extend ActiveSupport::Concern
included do |klass|
klass.primary_key = :id
klass.before_create do
self.id = UUID.generate
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment