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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5c262b1a445eb969fd2d411316f5365e?d=identicon&s=25 MaggotChild (Guest)
on 2009-01-12 08:20
(Received via mailing list)
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?
This topic is locked and can not be replied to.