Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:14:52+00:00 2026-06-08T08:14:52+00:00

I am passing a path as a parameter, so params[:path] would be name_path(:username =>

  • 0

I am passing a path as a parameter, so params[:path] would be name_path(:username => @user.name (I want to pass it as a path and not a url, so putting name_url in the params isn’t what I want).

Since you can only use redirect_to with a url, I need to change the path to a url before I can use redirect_to. How would I do this?

I found this method here

def path_to_url(path)
  "http://#{request.host_with_port_without_standard_port_handling}/#{path.sub(%r[^/],'')}"
end

But, this was written in 2008, and I want to know if there is a better way in Rails 3?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:14:54+00:00Added an answer on June 8, 2026 at 8:14 am

    Updated copy from original path to url post btw: also works on Rails 2

    # abs or /abs -> http://myx.com/abs
    # http://grosser.it/2008/11/24/rails-transform-path-to-url
    def path_to_url(path)
      "#{request.protocol}#{request.host_with_port.sub(/:80$/,"")}/#{path.sub(/^\//,"")}"
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best way to URL-encode a String representing URL path (not request
Hi I'm passing path string to Groovy Script from Scala like below but when
I am passing an object like this: -@users.each do |user| %tr %td=link_to(user.first_name, users_user_path(user), :title
Passing User defined argument to RPM is possible while installing?. for example: ~>rpm -i
passing post data using cURL requires that the name of the input. However, I
when passing parameters after index.php its showing 404 error .. its apache error not
When passing named parameters of the form :name to PDOStatement::bindParam() , it seems to
I am having issues passing a dynamic parameter to a JavaScript function using innerHTML.
I'm having a bit of trouble passing this parameter to a class i have.
1. Passing parameters into the service? If not already defined in the services.xml (or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.