title: Generating unique random string for identifying a record
body: <p>I have a requirement to be able to identify a record in a table, in this case a user table, by a unique key which does not give away the ordering of the records in the table.</p>
  
  <p>Currently I have primary key field and the routes that are generated look like:</p>
  
  <pre><code>/users/1
  </code></pre>
  
  <p>However, I'd like to be able to generate a route like:</p>
  
  <pre><code>/users/kfjslncdk
  </code></pre>
  
  <p>I can wire everything up on the route side, database side etc.. but I'm not sure what the best way to generate a unique string identifier would be in rails.  I'd like do something like:</p>
  
  <pre><code>before_save :create_unique_identifier
  
  def create_unique_identifier
      self.unique_identifier = ... magic goes here ...
  end
  </code></pre>
  
  <p>I was thinking I could use the first part of a guid created using UUIDTools, but I'd need to check to make sure it was unique before saving the user.</p>
  
  <p>Any advice would be greatly appreciated!</p>