title: before_create - Ruby on Rails
body: <blockquote>
  <p><strong>Possible Duplicate:</strong><br />
  <a href="https://stackoverflow.com/questions/6249475/ruby-on-rails-callback-what-is-difference-between-before-save-and-before-crea">Ruby on Rails Callback, what is difference between :before_save and :before_create?</a></p>
  </blockquote>
  
  <p>I'm looking to replace Ruby on Rails current id from /1, /2, /3, etc to a randomly generated URL, for example /csd8dsv68dvs.</p>
  <p>After looking into creating it, I found this in the post model</p>
  <pre><code>before_create { self.code = SecureRandom.hex(5) }
  </code></pre>
  <p>What does the before_create do and how can I implement the random id?</p>
  <h3>Update</h3>
  <p>It seems I got one part wrong. I'm not looking to change the ID, I just want to change the URL to a random string that a user won't be able to guess.</p>