[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Process POST data

Alin Alin

1/26/2007 9:31:00 PM

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.

--
Posted via http://www.ruby-....

2 Answers

Parragh Szabolcs

1/27/2007 9:30:00 AM

0

Alin Popa í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


> I want to display or use in other scope these parameters.
> How can this be done ?
>
> Thanks in advance.
>
> Alin.
>
>


--
Parragh Szabolcs
e-mail: parragh@dayka.hu
web: parszab.nir.hu


Alin Alin

1/27/2007 11:58:00 AM

0

Parragh Szabolcs wrote:
> Alin Popa �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

--
Posted via http://www.ruby-....