Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

link_to generates incorrect hrefs

#4147

link_to "Goodbye!", say_goodbye_path produces

<a href="http://localhost:3000/say/hello/say/goodbye">Goodbye!</a>

Broken by commit f38e2e03351da463f84f6850fa10718ece98ff26.

testcase, output, git bisect

Reported by Sam Ruby · March 10th, 2010 @ 04:16 PM

State: resolved
Milestone: 3.0.2
Assigned to: Carl Lerche Carl Lerche
Importance: High

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to open
    • Assigned user set to Carl Lerche

    March 11th, 2010 @ 12:09 AM

  2. Denis Odorcic
    Denis Odorcic
    • 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.

    March 16th, 2010 @ 05:50 AM

  3. Denis Odorcic
    Denis Odorcic

    Deleted the fix of an existing test as it was reverted a few minutes ago by b9c48f519

    March 16th, 2010 @ 06:00 AM

  4. Denis Odorcic
    Denis Odorcic
    • 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.

    March 16th, 2010 @ 06:54 AM

  5. José Valim
    José Valim

    Sam, this seems to be fixed on master. Could you please check?

    March 17th, 2010 @ 08:19 AM

  6. Denis Odorcic
    Denis Odorcic

    Looks like it has been fixed in master now, yes.

    March 17th, 2010 @ 12:55 PM

  7. José Valim
    José Valim
    • State changed from open to resolved

    March 17th, 2010 @ 09:31 PM

  8. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to High

    October 15th, 2010 @ 11:01 PM