Ruby : How to make a HttpRequest

181 Views Asked by At

I'm still new in ruby, please help. I'm trying to make a http request in my standalone ruby script.

#!/usr/bin/ruby
require 'rubygems'
require 'net/http'
...
class someClass
...
def get_ruby_doc
  request = HttpRequest.new(:get, 'http://www.ruby-doc.org/')
  response = request.perform!
  puts response.succeeded?
  puts "yeah"
end
...

when I run the script, I get this error:

Uncaught exception: uninitialized constant someClass::HttpRequest

Can you please let me know what did I miss? Thanks.

I also try to do the same in rails console, same error.

1

There are 1 best solutions below

0
On

You could try using rest-client

gem install rest-client

http://rubydoc.info/gems/rest-client/1.6.7/frames