title: Zipcode , to_i and leading zero in Ruby/Rails
body: <p>I am trying to save zip codes which are passed in the params as <code>"07306"</code>, and <code>"03452"</code>, but <code>to_i</code> seems to be converting these string values to <code>7306</code> and <code>3452</code> before validation, because of which the validation keeps failing.</p>
  
  <p>How do I prevent Ruby from removing the leading zeros?</p>
  
  <p>The zip code is an integer field in the database and the validation checks for the format of the zip using: </p>
  
  <pre><code>validates_format_of :zip, :with =&gt; /\A[+\-]?\d+\Z/, :message =&gt; "Please enter a valid US zipcode"
  </code></pre>