Created
August 13, 2012 20:51
-
-
Save chrislloyd/3344006 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create_table :users, id: false do |t| | |
t.uuid :id, primary: true, null: false | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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