# Url\_for not working when using aditional route parameters

**URL:** <https://www.ruby-forum.com/t/url-for-not-working-when-using-aditional-route-parameters/121703>\
**Category:** Rails\
**Created:** [November 30, 2007, 2:43am UTC](https://www.ruby-forum.com/t/url-for-not-working-when-using-aditional-route-parameters/121703 "2007-11-30T02:43:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vagostino](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e495f1/32.png) [@vagostino](https://www.ruby-forum.com/u/vagostino)\
**Post date:** [November 30, 2007, 2:43am UTC](https://www.ruby-forum.com/t/url-for-not-working-when-using-aditional-route-parameters/121703/1 "2007-11-30T02:43:32Z")

</div>

I have a couple routes where I need to send additional parameters  
every time _some_ routes in my app are called.

In order to stay DRY, it makes sense to set these parameters in the  
route, rather than passing them through for _every_ url\_for request.

Accordingly, I have defined a route as follows:

map.connect “sub\_dir/my\_friends/find”,  
:action=\>“search”,  
:controller=\>“friends”,  
:wrap\_in\_frame=\>true,  
:frame\_height=\>900

However, when I call url\_for, it doesn’t match the route, even when it  
is the _first_ route in my routes.rb.

url\_for( :action=\>“search”, :controller=\>“friends” ) generates the  
default route of “/friends/search”, and NOT the route I’ve specified  
above.

If I remove the additional parameters (wrap\_in\_frame and frame\_height)  
from the route definition, than the url\_for matches correctly.

Is it no longer possible to specify additional parameters when using  
routes and url\_for? The Agile Web D. book states that it is  
possible to do this, but it doesn’t seem to work.

Note that I don’t want to use :defaults on the route, because I don’t  
ever want the routes to show up in the url. Additionally, I don’t want  
to use named routes, because I have a lot of url\_for statements, and  
want to make sure that the additional parameters are set every time a  
certain path is called, regardless of whether a developer remembers to  
use the named route or not.

Am I doing something wrong, or is this functionality not supported?

Thanks in advance!
