[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Net::HTTP.post_form missing method error

Dan Tenenbaum

3/10/2006 12:07:00 AM

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/se...

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.ht...

...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-....


5 Answers

james_b

3/10/2006 12:21:00 AM

0

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



Dan Tenenbaum

3/10/2006 12:28:00 AM

0

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-....


james_b

3/10/2006 2:25:00 AM

0

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


Dan Tenenbaum

3/10/2006 2:47:00 AM

0

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-....


Mat

3/10/2006 6:47:00 AM

0

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-....