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.

skip_relative_url_root is broken

#1995

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.

Reported by Xavier Noria · February 16th, 2009 @ 10:03 PM

State: stale
Milestone: 3.x
Assigned to: Michael Koziarski Michael Koziarski
Importance: none

Activity

  1. Pratik
    Pratik
    • Assigned user set to Michael Koziarski

    February 16th, 2009 @ 10:06 PM

  2. Xavier Noria
    Xavier Noria
    • Assigned user cleared.

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

    February 16th, 2009 @ 10:20 PM

  3. Xavier Noria
  4. Pratik
    Pratik
    • Assigned user set to Michael Koziarski

    March 11th, 2009 @ 06:25 PM

  5. naruse
  6. naruse
    naruse

    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.

    October 26th, 2009 @ 06:18 PM

  7. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  8. Ryan Bigg
    Ryan Bigg
    • Importance changed from to

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

    October 11th, 2010 @ 04:45 AM

  9. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 19th, 2010 @ 08:25 AM

  10. Santiago Pastorino
    Santiago Pastorino
    • 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.

    February 2nd, 2011 @ 04:48 PM

  11. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:48 PM