How do I get params in rails that are only from the URL?
<p>I'm writing a rails mountable gem which fires custom javascript events based on what controller and action being rendered.</p>

<p>I would like to add a feature where the params from the URL are available to event handlers:</p>

<pre><code>// 'PATCH /users/:user_id/tasks/:id'
$(document).on('tasks#update', function(data, params){
  console.log(params['user_id'], params['id']);
});
</code></pre>

<p>For security reasons I would like to limit this to the params which originate from the URL and not from the request body.</p>

<p>Since this is library and not application code I can't just use <code>URI.parse</code> as the key mappings are not known.</p>

<p>How do I get a subset of the params that are only the router matches?</p>