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

  • SEARCH
  • Home
  • 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 642807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:12:49+00:00 2026-05-13T21:12:49+00:00

I am generating a url in my controller accessed from the relative path /hangouts/test,

  • 0

I am generating a url in my controller accessed from the relative path “/hangouts/test”, for a url on an external site (facebook). I want to use url_for and pass in params using hashes so it can escape them. The URL I want is this:

http://www.facebook.com/connect/prompt_permissions.php?api_key=6aca22e72866c7eaaedfb15be69c4b93&…

Using this, however:

url_for(:host => "www.facebook.com/connect/prompt_permissions.php?", :api_key => Facebooker.api_key, :next => test_hangouts_url, :cancel => root_url, :ext_perm  => "publish_stream")

I instead get my current path of /hangouts/test thrown in there:

http://www.facebook.com/connect/prompt_permissions.php/hangouts/test?api_key=6aca22e72866c7eaaedfb15be69c4b93&…

As you can see, I don’t want “/hangouts/test” to be in there – played a bit with the options in the API docs but stumped, anybody know how to use url_for without it inserting the current path? Thanks!

  • 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-05-13T21:12:50+00:00Added an answer on May 13, 2026 at 9:12 pm

    You shouldn’t be using the hash form of url_for to generate links outside of your application.

    Instead you should just be using the string version form:

    url_for "http://www.facebook.com/connect/prompt_permissions.php?api_key=6aca22e72866c7eaaedfb15be69c4b93&next=#{test_hangouts_url}&cancel=#{root_url}&ext_perm=publish_stream"
    

    url_for will use the current action controller/action/id unless the hash given to url_for contains one of those arguments. url_for will then generate a url from a route that matches the arguments given in the hash. The arguments to url_for used in the question generates a valid url, because it can match a route using the current controller/action. You will not be able to generate the url you want with the hash form of url for without matching a route. Providing a controller in the hash you give url_for should match the default routes that rails generates for you when you create an application, but that’s not very DRY.

    The better solution is to use a named route:

    map.prompt_fb_permissions "/connect/prompt_permissions.php", 
      :host => "www.facebook.com", :controller => nil, :action => nil
    

    then you can use the following in place of url_for whenever you want to generate this this url.

    prompt_fb_permissions(:api_key => Facebooker.api_key, :next => test_hangouts_url, 
      :cancel => root_url, :ext_perm  => "publish_stream")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the resource routes, you can do things like url_for(@apple) to get a url
Im generating a report from a template html file in my program. It resides
I am developing the ASP.NET MVC 2 application . I want to show the
i am trying to make a pdf file with wkhtmltopdf when i pass url
I am using Google App Engine mapreduce to analyze some data. I am generating
So, I'm a bit new to rails routing, especially with querystrings. I'm looking to
I am currently reorganizing a Play! project where there is a lot of JS
I have an MVC 2 app that has a System.Timers.Timer object starting up during
History: I created a key and pem file on Amazon. I created a private
I need to develop a feature in the system which allows unregistered users to

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.