This project is archived and is in readonly mode.

#1995 ✓stale
Xavier Noria

skip_relative_url_root is broken

Reported by Xavier Noria | February 16th, 2009 @ 10:03 PM | in 3.x

The current implementation of skip_relative_url_root is broken:

  • if :only_path is true this option is ignored

  • if :only_path is false the relative_url_root is prefixed but "skip_relative_url_root=true" appears in the query string.

I attach a patch that fixes this.

Comments and changes to this ticket

  • Pratik

    Pratik February 16th, 2009 @ 10:06 PM

    • Assigned user set to “Michael Koziarski”
  • Xavier Noria

    Xavier Noria February 16th, 2009 @ 10:20 PM

    • Assigned user cleared.

    I got the name of two tests reversed, patch updated.

  • Xavier Noria
  • Pratik

    Pratik March 11th, 2009 @ 06:25 PM

    • Assigned user set to “Michael Koziarski”
  • naruse
  • naruse

    naruse October 26th, 2009 @ 06:18 PM

    This bug is correct and the patch above also correct for me.
    Please merge it.

    :skip_relative_url_root is used for ignoring ActionController::Base.relative_url_root.

    ActionController::Base.relative_url_root is needed when you run rails in relative environment
    for example rails run in http://example.com/foobar/ not http://foobar.example.com/.
    ActionController::Base#url_for and related methods uses this and returns correct paths, for example /foobar/users/new for new_user_path.

    But you sometimes want to get paths without such paths with relative_url_root,
    for example the code runs as batch kicked by mail or cron.

    Though current code removes :skip_relative_url_root before they use it.
    The patch above moves removing it to after use it.
    This should be correct.

    else

          # Delete the unused options to prevent their appearance in the query string.
    
    •   [:protocol, :host, :port, :skip_relative_url_root].each { |k| options.delete(k) }
      
    •   [:protocol, :host, :port].each { |k| options.delete(k) }
      end
      trailing_slash = options.delete(:trailing_slash) if options.key?(:trailing_slash)
      
      +
      url << ActionController::Base.relative_url_root.to_s unless options[:skip_relative_url_root]
      

    So this bug and its patch is correct, please merge it.

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Ryan Bigg

    Ryan Bigg October 11th, 2010 @ 04:45 AM

    • Importance changed from “” to “”

    Xavier, now that you have commit rights to Rails (or so I think?), perhaps you could commit this yourself?

  • Ryan Bigg

    Ryan Bigg October 19th, 2010 @ 08:25 AM

    • Tag cleared.

    Automatic cleanup of spam.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:48 PM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:48 PM

    • State changed from “open” to “stale”
  • klkk

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

Referenced by

Pages