Forum: Ruby on Rails url_for, routes, and the current url

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
MaggotChild (Guest)
on 2009-01-12 09:20
(Received via mailing list)
I need to generate 2 types of URL  and have defined my routes as:

yes", :controller=>"posts", :action=>"country", :yes=>true
no", :controller=>"posts", :action=>"country", :yes=>false

map.yes "/yes", :controller=>"posts", :action=>"index", :yes=>true "/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
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?
This topic is locked and can not be replied to.