Skip to content

Instantly share code, notes, and snippets.

@brainwire
Last active February 9, 2017 20:04
Show Gist options
  • Save brainwire/ed97b9130cc9b4604e63d466f40d256a to your computer and use it in GitHub Desktop.
Save brainwire/ed97b9130cc9b4604e63d466f40d256a to your computer and use it in GitHub Desktop.
UUIDs
Enabling UUIDs by default in Rails apps is easy. Just edit the config file:
# config/application.rb
config.active_record.primary_key = :uuid
You can use UUIDs for an individual table with Rails migrations:
create_table :users, id: :uuid do |t|
t.string :name
end
#Use
SecureRandom.uuid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment