loyalflow
loyalflow

Reputation: 14879

Using guids for all model ids

What would it take, in a new rails application, to use GUID's instead of integers for id's in my models?

Are there any 'gotchas' when doing this?

Upvotes: 2

Views: 1976

Answers (1)

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

There's a gem for that!: https://github.com/jashmenn/activeuuid

Your migrations look like:

create_table :user do |t|
  t.uuid :id, :primary_key => true
end

And you model looks like:

class User < ActiveRecord::Base
  include ActiveUUID::UUID
end

All code above taken/inspired from the readme

Upvotes: 3

Related Questions