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")
evt.id # => "0302b647-cdd8-4ecd-95c2-321796109a9a"
SecureRandom is in the stdlib since 1.9.2 (but you should use 2.x)
Written by Arnaud Meuret
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#