Forum: Ruby Net::HTTP.post_form missing method error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dan T. (Guest)
on 2006-03-10 02:06
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/rdo...

...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.
James B. (Guest)
on 2006-03-10 02:21
(Received via mailing list)
Dan T. 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?
Dan T. (Guest)
on 2006-03-10 02:27
James B. wrote:
> Dan T. 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.
James B. (Guest)
on 2006-03-10 04:25
(Received via mailing list)
Dan T. 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 B.

"The greatest obstacle to discovery is not ignorance, but the illusion
of knowledge."
  - D. Boorstin
Dan T. (Guest)
on 2006-03-10 04:47
James B. wrote:
> Dan T. 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.
Mat (Guest)
on 2006-03-10 08:46
Dan T. 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
This topic is locked and can not be replied to.