# Process POST data

**URL:** <https://www.ruby-forum.com/t/process-post-data/83522>\
**Category:** Ruby\
**Created:** [January 26, 2007, 10:30pm UTC](https://www.ruby-forum.com/t/process-post-data/83522 "2007-01-26T22:30:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chucky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b782af/32.png) [@chucky](https://www.ruby-forum.com/u/chucky)\
**Post date:** [January 26, 2007, 10:30pm UTC](https://www.ruby-forum.com/t/process-post-data/83522/1 "2007-01-26T22:30:27Z")

</div>

Hi to all,

Recently, I had one little problem regarding Ruby and Processing POST  
requests from a HTML form.  
I know that there is Webrick for Servlets and stuff, but I want to know,  
there is possible to process POST/GET requests with basic net/http and  
mod\_ruby?

I have one ruby script that receive some data from one html page  
POST/GET.  
I want to display or use in other scope these parameters.  
How can this be done ?

Thanks in advance.

Alin.

---

<div class="post-metadata">

**Author:** ![chucky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b782af/32.png) [@chucky](https://www.ruby-forum.com/u/chucky)\
**Post date:** [January 27, 2007, 10:31am UTC](https://www.ruby-forum.com/t/process-post-data/83522/2 "2007-01-27T10:31:12Z")

</div>

Alin P. írta:

> I have one ruby script that receive some data from one html page  
> POST/GET.

The easy way is to make a new CGI object in your script, that mod\_ruby  
runs, and ask for the parameters, POST-ed ones will be there, too.

E.g: in your ruby script file:

require ‘cgi’

cgi = CGI.new  
get\_data(cgi)

def get\_data(cgi)  
user = User.new  
User.name = cgi[‘name’]  
User.age = cgi[‘age’]  
…  
end

---

<div class="post-metadata">

**Author:** ![chucky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b782af/32.png) [@chucky](https://www.ruby-forum.com/u/chucky)\
**Post date:** [January 27, 2007, 12:58pm UTC](https://www.ruby-forum.com/t/process-post-data/83522/3 "2007-01-27T12:58:20Z")

</div>

Parragh S. wrote:

> Alin P. ï¿½rta:
> 
> > I have one ruby script that receive some data from one html page  
> > POST/GET.
> 
> The easy way is to make a new CGI object in your script, that mod\_ruby  
> runs, and ask for the parameters, POST-ed ones will be there, too.
> 
> E.g: in your ruby script file:
> 
> require ‘cgi’
> 
> cgi = CGI.new  
> get\_data(cgi)
> 
> def get\_data(cgi)  
> user = User.new  
> User.name = cgi[‘name’]  
> User.age = cgi[‘age’]  
> …  
> end

Thanks Parragh,

Great help, with one small notice:

I used exactly your example, BUT I called the method get\_data, after  
declaration of it, because if I call it before, I’ll get 500 Internal  
Server Error.

Best regards,

Alin
