Last Updated: February 25, 2016
· arnaudm

Using UUIDs with Redis Ohm

Ohm creates incremental object ids by default but you can explicitly override this at creation time if you want to use UUIDs (and you should).

require 'securerandom'

evt = Event.create(id: SecureRandom.uuid, name: "Concert") # => "0302b647-cdd8-4ecd-95c2-321796109a9a"

SecureRandom is in the stdlib since 1.9.2 (but you should use 2.x)