title: Converting an array of strings into a key-value pair
body: <p>I have an array as the value of a hash:</p>
  
  <pre><code>:params=&gt;[":centre_id", ":id"]
  </code></pre>
  
  <p>I am trying to find a way to convert each element of the array to something like this:</p>
  
  <pre><code>:centre_id =&gt; 1
  :id =&gt; 1
  </code></pre>
  
  <p>I tried loads of different ways but I can't seem to find a nice clean way to do it:</p>
  
  <pre><code>"#{route[:params].map {|x| x.parameterize.underscore.to_sym =&gt; '1'}}"
  </code></pre>
  
  <p>This is what I am trying to achieve:</p>
  
  <pre><code>-{"controller"=&gt;"venues", "action"=&gt;"activity, {:centre_id=&gt;1, :id=&gt;1}"}
  +{"controller"=&gt;"venues", "action"=&gt;"activity", "centre_id"=&gt;"1", "id"=&gt;"1"} &lt;&lt; this one
  
      string or symbol doesn't matter does it?
  </code></pre>
  
  <p>Using this:</p>
  
  <pre><code>expect(route[:request_method] =&gt; route[:path]).to route_to "#{route[:controller]}##{route[:action]}, #{Hash[route[:params].map {|x| [x.sub(/\A:/,'').to_sym, 1] }]}" 
  </code></pre>
  
  <p>Help would be much appreciated.</p>