Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails Net::HTTP use_ssl throws 'undefined method'

Here's my code:

sock = Net::HTTP.new(url.host, url.port)
sock.use_ssl = true
response = sock.start {|http| http.request(req)}

here's the error:

undefined method `use_ssl=' for #<Net::HTTP www.paypal.com:443 open=false>

google is getting me nothing!

thanks.

like image 384
Chris Avatar asked Sep 26 '10 00:09

Chris


1 Answers

Require 'net/https' in addition to 'net/http'. Then use_ssl= will be defined.

require 'net/http'
require 'net/https'
connection = Net::HTTP::new 'www.example.com'
connection.use_ssl = true
like image 191
DGM Avatar answered Oct 14 '22 20:10

DGM