# Net::HTTP.post\_form missing method error

**URL:** <https://www.ruby-forum.com/t/net-http-post-form-missing-method-error/54614>\
**Category:** Ruby\
**Created:** [March 10, 2006, 1:06am UTC](https://www.ruby-forum.com/t/net-http-post-form-missing-method-error/54614 "2006-03-10T01:06:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [March 10, 2006, 1:06am UTC](https://www.ruby-forum.com/t/net-http-post-form-missing-method-error/54614/1 "2006-03-10T01:06:24Z")

</div>

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 = “[Google](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](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.

---

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [March 10, 2006, 1:21am UTC](https://www.ruby-forum.com/t/net-http-post-form-missing-method-error/54614/2 "2006-03-10T01:21:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [March 10, 2006, 1:27am UTC](https://www.ruby-forum.com/t/net-http-post-form-missing-method-error/54614/3 "2006-03-10T01:27:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [March 10, 2006, 3:25am UTC](https://www.ruby-forum.com/t/net-http-post-form-missing-method-error/54614/4 "2006-03-10T03:25:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [March 10, 2006, 3:47am UTC](https://www.ruby-forum.com/t/net-http-post-form-missing-method-error/54614/5 "2006-03-10T03:47:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [March 10, 2006, 7:46am UTC](https://www.ruby-forum.com/t/net-http-post-form-missing-method-error/54614/6 "2006-03-10T07:46:26Z")

</div>

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
