Skip to content

Instantly share code, notes, and snippets.

@brainwire
Last active February 9, 2017 20:04

Revisions

  1. @wadik wadik revised this gist Feb 9, 2017. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion UUID.rb
    Original file line number Diff line number Diff line change
    @@ -6,4 +6,7 @@

    create_table :users, id: :uuid do |t|
    t.string :name
    end
    end

    #Use
    SecureRandom.uuid
  2. @wadik wadik created this gist Feb 9, 2017.
    9 changes: 9 additions & 0 deletions UUID.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    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