# Routes: query parameter keys and significant keys in routes

**URL:** <https://www.ruby-forum.com/t/routes-query-parameter-keys-and-significant-keys-in-routes/87805>\
**Category:** Rails\
**Created:** [March 6, 2007, 2:23am UTC](https://www.ruby-forum.com/t/routes-query-parameter-keys-and-significant-keys-in-routes/87805 "2007-03-06T02:23:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 6, 2007, 2:23am UTC](https://www.ruby-forum.com/t/routes-query-parameter-keys-and-significant-keys-in-routes/87805/1 "2007-03-06T02:23:28Z")

</div>

I’m currently facing a problem where I’d like to take parameter which  
is encoded into the path portion of the URL via routes on one page,  
and add it as a query parameter for a link to a subsequent page  
(linked on the current page). I would like the query parameter to be  
keyed by the same key that is used on the current page in the route.  
Here is the example:

map.connect ‘/:search\_term/:foo/:bar’, …  
map.connect ‘/:foo/:bar/:baz’, …

I am currently on page a (the first route), and have a link to page  
b(second route). In the link\_to method, I pass the key/value pair  
{:search\_term =\> ‘foo’}, but it does not appear as a query parameter  
on this generated link.

The code in ActionController::Routing that removes this is:

def extra\_keys(hash, recall={})  
(hash || {}).keys.map { |k| k.to\_sym } - (recall || {}).keys -  
significant\_keys  
end

Hash is the newparameter options, and recall is the hash of current  
parameters. Why would you subtract recall from hash when figuring out  
which keys are going to be appended as query parameter keys?

Best,  
Alex
