Reputation: 13
I need to call some php script from ROR controller, so I tried to use open("url"), but it didn't work.
For example,
def successful_login
open("http://stackoverflow.com")
redirect_to home_url
end
Errno::EINVAL in UsersController#create
Invalid argument - http://stackoverflow.com
Any idea?
Upvotes: 0
Views: 3628
Reputation: 825
require 'net/http' require 'uri'
url = URI.parse('http://www.example.com/index.html')
res = Net::HTTP.start(url.host, url.port) {|http|
http.get('/index.html')
}
puts res.body
Upvotes: 0
Reputation: 3866
require 'net/http'
Net::HTTP.get('www.example.com', '/index.html')
Upvotes: 0