title: how to extract multiple integer from string in rails
body: <p>I have the following in my url. I need to extract both 4 and 2 separately for the purpose of searching. These two integer, <code>one is category id</code> and other is <code>sub category id</code></p>
  
  <pre><code>params[:id].scan(/\d+$/).first
  </code></pre>
  
  <p>using the above scan i can get <code>4</code> but how can i get more than one integers</p>
  
  <pre><code>my-url-for-test-4-2
  </code></pre>
  
  <p>I have created a helper method</p>
  
  <pre><code>  def string_to_int(param,key)
      param.scan(/\d+/).map(&amp;:to_i).key
    end
  </code></pre>
  
  <p>And i tried it from my controller like this</p>
  
  <pre><code>id = string_to_int(params[:id],'first')
  </code></pre>
  
  <p>But getting error as</p>
  
  <pre><code>undefined method `key' for [4, 2]:Array
  </code></pre>
  
  <p>Why it is not acception.</p>