Net::HTTP.post_form missing method error

D

Dan Tenenbaum

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", :eek:e => "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.
 
J

James Britt

Dan said:
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?
 
D

Dan Tenenbaum

James said:
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.
 
J

James Britt

Dan said:
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
 
D

Dan Tenenbaum

James said:
Dan said:
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.
 
M

Mat

Dan said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top