Net::HTTP.post_form missing method error

I had some code that used to work and now all of a sudden it stopped
working. Here is the minimal code to illustrate the problem:

#!/usr/bin/ruby
require 'net/http'
require 'uri'
parms = {:client=>"safari", :rls=>"en", :q => "myquery",
  :ie => "UTF-8", :oe => "UTF-8"}
url = "http://www.google.com/search"

res = Net::HTTP.post_form(URI.parse(url), parms)

print res.body
print

The code fails with this error:
./foo.rb:8: undefined method `post_form' for Net::HTTP:Class
(NoMethodError)

However, my code is almost identical to the example at:
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html#M001204

...which presumably should work.

This is on a mac. I tried it on a windows box and it failed with the
same error. I tried it on a linux box and it worked (the request format
isn't quite right, but *something* came back from the server and was
printed out, so for the purposes of this post, it "works").

Anyone have any ideas as to why? Apparently I have the Net::HTTP class
but it doesn't have the post_form method in it....anymore....

Hope someone can help.

···

--
Posted via http://www.ruby-forum.com/.

Dan Tenenbaum wrote:

I had some code that used to work and now all of a sudden it stopped working. Here is the minimal code to illustrate the problem:

What version of ruby are you using on each platform?

···

--
James Britt

James Britt wrote:

Dan Tenenbaum wrote:

I had some code that used to work and now all of a sudden it stopped
working. Here is the minimal code to illustrate the problem:

What version of ruby are you using on each platform?

Mac OX 10.4: ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
Linux: ruby 1.8.3 (2005-09-21) [i686-linux]
Win XP SP2: ruby 1.8.2 (2004-12-25) [i386-mswin32]

Again, it works on linux but not on Mac or Win.

···

--
Posted via http://www.ruby-forum.com/\.

Dan Tenenbaum wrote:

Mac OX 10.4: ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
Linux: ruby 1.8.3 (2005-09-21) [i686-linux]
Win XP SP2: ruby 1.8.2 (2004-12-25) [i386-mswin32]

Again, it works on linux but not on Mac or Win.

Because, I believe, that method was added in 1.8.3.

···

--
James Britt

"The greatest obstacle to discovery is not ignorance, but the illusion of knowledge."
  - D. Boorstin

James Britt wrote:

Dan Tenenbaum wrote:

Mac OX 10.4: ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
Linux: ruby 1.8.3 (2005-09-21) [i686-linux]
Win XP SP2: ruby 1.8.2 (2004-12-25) [i386-mswin32]

Again, it works on linux but not on Mac or Win.

Because, I believe, that method was added in 1.8.3.

Duh. Thanks. Can someone tell me the least painful way to upgrade my
Ruby installation?
I am using Locomotive on the mac for Rails development, but there is
also a ruby in /usr/bin.

···

--
Posted via http://www.ruby-forum.com/\.

Dan Tenenbaum wrote:

Duh. Thanks. Can someone tell me the least painful way to upgrade my
Ruby installation?
I am using Locomotive on the mac for Rails development, but there is
also a ruby in /usr/bin.

Locomotive has Ruby and all the gems self-contained, inside the
Locomotive.app icon/folder/thing. If you are going to continue using
Locomotive, make sure you update the one inside that directory, and NOT
the one in /usr/bin, which isn't used in this env. Sorry, I don't know
how to do that, I would check on the locomotive site itself.

Mat Cucuzella

···

--
Posted via http://www.ruby-forum.com/\.