# Url\_for, routes, and the current url

**URL:** <https://www.ruby-forum.com/t/url-for-routes-and-the-current-url/157483>\
**Category:** Rails\
**Created:** [January 12, 2009, 8:20am UTC](https://www.ruby-forum.com/t/url-for-routes-and-the-current-url/157483 "2009-01-12T08:20:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaggotChild](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@MaggotChild](https://www.ruby-forum.com/u/MaggotChild)\
**Post date:** [January 12, 2009, 8:20am UTC](https://www.ruby-forum.com/t/url-for-routes-and-the-current-url/157483/1 "2009-01-12T08:20:22Z")

</div>

I need to generate 2 types of URL and have defined my routes as:

map.country\_yes  
“/:country/  
yes”, :controller=\>“posts”, :action=\>“country”, :yes=\>true  
map.country\_no  
“/:country/  
no”, :controller=\>“posts”, :action=\>“country”, :yes=\>false

map.yes “/yes”, :controller=\>“posts”, :action=\>“index”, :yes=\>true  
map.no “/no”, :controller=\>“posts”, :action=\>“index”, :yes=\>false

The problem is that, when a request if for /yes or /no, url\_for()  
doesn’t generate URLs for the country.

url\_for(:yes=\>true) generates the correct url no matter where its  
used.  
if the current request is for /no it generates /yes.  
if its for /mexico/no, it generates /mexico/yes

though this is not the same when trying to generate URLs for country.  
If the request is at /no  
url\_for(:country=\>‘usa’,:yes=\>true) generates /no and tacks on ‘usa’  
and ‘yes’ as query string parameters instead of generating /usa/yes.

Why is this taking place?
