This project is archived and is in readonly mode.
link_to generates incorrect hrefs
Reported by Sam Ruby | March 10th, 2010 @ 04:16 PM | in 3.0.2
link_to "Goodbye!", say_goodbye_path
produces
<a href="http://localhost:3000/say/hello/say/goodbye">Goodbye!</a>
Broken by commit f38e2e03351da463f84f6850fa10718ece98ff26.
Comments and changes to this ticket
-
Jeremy Kemper March 11th, 2010 @ 12:09 AM
- State changed from new to open
- Assigned user set to Carl Lerche
-
Denis Odorcic March 16th, 2010 @ 05:50 AM
- Tag set to default_url_options, patch, script_name, url_for
So I looked into this issue and it seems that script_name was introduced to url_for's url_options. It then gets prepended to the path that url_for generates, however it should only be prepending it when the user passes it in as far as I can tell. In this example, say/hello is the script name that the controller picks up and ends up prepending it to say/goodbye.
I've attached a patch, a couple of tests for the above cases I described, and also a 3rd fix on an existing test that failed after I made this fix. I took a close look at the test and as far as I can tell there's no reason that its url should have 'bar' in it, but if someone could double check that would be great.
-
Denis Odorcic March 16th, 2010 @ 06:00 AM
Deleted the fix of an existing test as it was reverted a few minutes ago by b9c48f519
-
Denis Odorcic March 16th, 2010 @ 06:54 AM
- Tag changed from default_url_options, patch, script_name, url_for to default_url_options, script_name, url_for
Spoke too soon, not all tests were passing, at least you guys are pointed in the right direction :) I think the failing tests I added should be correct though, so I'll leave that up here.
-
José Valim March 17th, 2010 @ 08:19 AM
Sam, this seems to be fixed on master. Could you please check?
-
José Valim March 17th, 2010 @ 09:31 PM
- State changed from open to resolved
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to High
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>