title: Ruby on Rails: Interpreting a form input as an integer
body: <p>I've got a form that allows the user to put together a hash.</p>
  
  <p>The hashes desired end format would be something like this:<br>
  {1 => "a", 2 => "x", 3 => "m"}</p>
  
  <p>I can build up something similar by having lots of inputs that have internal brackets in their names:  </p>
  
  <pre><code>&lt;%= hidden_field_tag "article[1]", :value =&gt; a %&gt;
  </code></pre>
  
  <p>However, the end result is that builds a hash where all the keys are strings and not integers:<br>
  {"1" => "a", "2" => "x", "3" => "m"}</p>
  
  <p>I'm currently fixing this by generating a new hash in the controller by looping over the input hash, and then assigning that to params. Is there a cleaner, DRYer way to do this?</p>