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?