Ruby – How to make a HTTP request using Ruby on Rails


I would like to take information from another website. Therefore (maybe) I should make a request to that website (in my case a HTTP GET request) and receive the response.

How can I make this in Ruby on Rails?

If it is possible, is it a correct approach to use in my controllers?

Best Solution

You can use Ruby's Net::HTTP class:

require 'net/http'

url = URI.parse('')
req =
res = Net::HTTP.start(, url.port) {|http|
puts res.body