This project is archived and is in readonly mode.

#566 ✓wontfix
David Eisinger

link_to with single string argument

Reported by David Eisinger | July 7th, 2008 @ 06:14 PM | in 2.x

Currently, calling the link_to helper method with a single string argument generates a link with the given string as the link text and the current URL as the linked URL. This patch makes it so that the given string is used as both the link text and the link URL. In other words,

link_to("http://www.rubyonrails.org")

will now generate the following link:

http://www.rubyonrails.org

Comments and changes to this ticket

  • Ryan Bates

    Ryan Bates July 7th, 2008 @ 09:48 PM

    You can use auto_link for this.

    auto_link "http://www.rubyonrails.org"
    

    That probably isn't as efficient performance wise, so I would still like to see this patch accepted.

  • Chris Barnett

    Chris Barnett July 8th, 2008 @ 04:58 AM

    I think this is a good idea, but I'm not sure about the implementation.

    I've always been able to do

    <%= link_to "Somewhere" %>
    

    To create a placeholder for a real link which will be added later. It renders as:

    <a href="/path/to/the/current/page">Somewhere</a>
    

    This is great for mocking up a page; but with this patch applied, the same link_to becomes:

    <a href="Somewhere">Somewhere</a>
    

    Placeholder links will now give 404 errors instead of just reloading the page.

    Is anyone else using link_to this way?

  • Pratik

    Pratik August 3rd, 2008 @ 02:31 PM

    • State changed from “new” to “wontfix”

    Should just use auto_link.

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>

Attachments

Pages