open url in ruby controller
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 - ht开发者_运维问答tp://stackoverflow.comAny idea?
require 'net/http'
Net::HTTP.get('www.example.com', '/index.html')
The API docs
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
精彩评论