title: How do I ensure unique id is indeed unique in Rails?
body: <p>I want to replace an object's url from <code>/object/123</code> to <code>/object/f8a3b2</code>, so instead of using the <code>id</code> column I'm generating an <code>uid</code> column manually when the object is created.</p>
  
  <p>I can use the uuid libraries available to generate uid, but how do I make sure that the generated value is always unique?</p>
  
  <p>I have a unique index set on the uid column, so if it's not unique, it should throw back an error - can I catch that on the model level, create another uid, and try again?</p>