title: How to make model IDs in Rails unpredictable and random
body: <p>I'm writing a rails app that, by its nature, CANNOT require users to register, and thus cannot use authentication as the usual means to protect records. (I know, I know...)   User information here is limited to email addresses. So I do need a way to make my model IDs unpredictable so that other IDs cannot be easily guessed. (I know, I know...)</p>
  
  <p>I have tried using plugins like uuidtools to randomize ids as records are created, like so:</p>
  
  <pre><code>require 'uuidtools'
  class Post &lt; ActiveRecord::Base 
   def before_create() 
    self.id = OpenSSL::Digest.SHA1.hexdigest(UUID.timestamp_create()) 
   end 
  end 
  </code></pre>
  
  <p>...This looks good at first, but funny things happen. ActiveRecord sometimes tries to insert a 0 value into the id and I get errors such as 'can't find Post with id=0' etc...</p>
  
  <p>I've run out of ideas. Can anyone help? Thanks.</p>