1

Now that I am able to make a "simple" HTTP GET request from a "first website" to a "second website", how is it possible to pass parameters safely in the URL using Ruby (on Rails)?

URL example for the GET request: http ://www.example.com/index.html?param1=test1&param2=test2

Then, in a "second website", I need to read parameters passed from the HTTP GET request of the "first website" to prepare the response. How can I make that?

Community
  • 1
  • 1
user502052
  • 14,803
  • 30
  • 109
  • 188

1 Answers1

2

Any parameters used in the request will be available to your controller in the params hash (link has more details).

Here's a basic example of getting the individual parameters based on their key.

def index
  @param1 = params[:param1]
  @param2 = params[:param2]

  puts @param1 # => test1
  puts @param2 # => test2
end
Peter Brown
  • 50,956
  • 18
  • 113
  • 146
  • Beerlington's answer is what you're looking for, HOWEVER, browsers generally truncate long URLs, and some servers wont allow an excessively large GET request. You may want to consider POST with cURL (or similar) if you are sending a large number of parameters/long data – sethvargo Jan 03 '11 at 04:55