This project is archived and is in readonly mode.

#6500 ✓invalid
Evan Light

url_for does not automatically :only_path => false when :host is set

Reported by Evan Light | March 2nd, 2011 @ 12:18 AM

Docs claim otherwise.

Comments and changes to this ticket

  • Evan Light

    Evan Light March 2nd, 2011 @ 12:32 AM

    Specifically, docs for url_for claim :only_path defaults to false. However, setting :host without explicitly specifying :only_path => false results in a relative url.

    That is:

    url_for foo, :host => "bla.com"
    

    ... provides a relative path but ...

    url_for foo, :host => "bla.com", :only_path => false
    

    ... provides an absolute path.

  • Evan Light

    Evan Light March 2nd, 2011 @ 12:40 AM

    Er... replace "foo" with a controller and action. ;-)

  • Evan Light

    Evan Light March 2nd, 2011 @ 12:47 AM

    More specifically, this only happens when using a named route helper. Using url_for directly works fine.

  • Evan Light

    Evan Light March 2nd, 2011 @ 01:17 AM

    Please close this. Not a bug. Perhaps the documentation could use an update to remind people that url defaults to :only_path => false and path defaults to :only_path => true.

  • Andrew White

    Andrew White March 3rd, 2011 @ 05:58 PM

    • State changed from “new” to “invalid”
    • Importance changed from “” to “Low”

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>

Tags

Pages