How do I handle an HTML form from ruby?

Having Ruby start a browser with the correct form.html file is easy enough.
I suspect the tricky part for you is after the user hits the ‘Submit’
button. That is usually tied to an Action that is typically another web
page. At this point, an HTTP server is required (thus the Apache
recommendation). That’s because when the browser goes to find the Action
web page, it expects to be able to communicate to a Web server that is
listening on a particular port for web requests. Communication through this
port to the web server is how the parameters from the form will get passed
to the Action page.

I suppose you could write a Ruby program that would listen on a particular
port (7829 spells Ruby on the phone keypad!) and maybe could handle it the
communication. Is that what you’re thinking of? But in this case you’re
repeating the communication code that is already written in Apache.

Drew

···

-----Original Message-----
From: Ludwigi Beethoven [mailto:aix_tech@yahoo.com]
Sent: Thursday, August 21, 2003 12:28 PM
To: ruby-talk@ruby-lang.org
Subject: Re: How do I handle an HTML form from ruby?

OK, first thank you for your help.
Now, let me make an attempt to explain what I want to
do.

On my quest to learn ruby, I wanted to design a simple
address book application. I wanted to be able to
display some kind of window/form with entry fields for
the mundane items that goes on a phone/address book.
First I thought about using a GUI interfact Tk/Fox.
Then I thought about using something simpler and more
“standard” to collect the data. So after reading about ruby
sopporting html forms and since the majority of the systems
out there use some kind of browser, I thought that perhaps I
could use html ruby support. But it appears that although it
is easy to design the form, it is not that easy to display
it. I wanted to capture input data (phones, addresses,
etc.) and output the same type of data, after a
search.

Thank you

— Pit Capitain pit@capitain.de wrote:

On 21 Aug 2003 at 11:52, Ludwigi Beethoven wrote:

No, I don’t have an HTTP server running. I guess I
could install apache, but I thought that it was
much
simpler.
All the examples make it look simple. Oh well!

Ludwigi, I’m not sure what you want exactly.

I am trying to learn how to manipulate HTML
files
with
ruby at the same time that I learn HTML. I
created
a
simple html file that contains among other
things,
input text fields and some buttons.

What do you mean by “manipulate”? Do you want to
treat an HTML file
as text and do some processing on it, for example
extracting the URL
of an image, or do you want to build a web
application that processes
the user input in some way?

The problem now is:

How do I tell ruby to run the html file?

What do you mean by “run” the file? If you only want
to look at it,
then you just …

Do I need to passit to a browser and if so,
how?

… open the file in your browser (usually via the
File/Open menu).

How do I capture user’s input?

This is where you start building a web application.
If you press the
submit button in the browser, the browser sends the
user’s input via
the HTTP protocol somewhere (the target being
mentioned in the
tag). So you need a program that is able to process
the data. I
suppose you want to use a Ruby program for that. If
so, then you have
several choices, for example Webrick (look in the
RAA).

HTH

Regards,
Pit


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design
software http://sitebuilder.yahoo.com

I installed Eclipse and the ruby plug-in for it.
However, I don’t see anyway to use it and create
widgets.
Do anyone outthere have any sample code or any
instructions on how to use Eclipse and ruby together?

Thank you

···

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Thank you Nathaniel.

I installed Eclipse and the ruby plug-in for it.
However, I don’t see anyway to use it and create
widgets.
Do anyone outthere have any sample code or any
instructions on how to use Eclipse and ruby
together?

At this point the Ruby Eclipse plugin only allows the
editing/running/debugging of Ruby code; unfortunately,
there is no ability
to script Eclipse itself using Ruby.

Nathaniel

<:((><

···

Ludwigi Beethoven [mailto:aix_tech@yahoo.com] wrote:


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

At this point the Ruby Eclipse plugin only allows the
editing/running/debugging of Ruby code; unfortunately, there is no ability
to script Eclipse itself using Ruby.

Nathaniel

<:((><

···

Ludwigi Beethoven [mailto:aix_tech@yahoo.com] wrote:

I installed Eclipse and the ruby plug-in for it.
However, I don’t see anyway to use it and create
widgets.
Do anyone outthere have any sample code or any
instructions on how to use Eclipse and ruby together?

Now there’s a good idea. Elsewhere I suggested the ability to call
Perl modules from Ruby. It would be just as great to be able to call
Java from Ruby. Java has pretty good reflection, so it shouldn’t be too
hard to build dynamic wrappers for Java objects…

Ludwigi Beethoven wrote:

···

Thank you Nathaniel.

Ludwigi Beethoven [mailto:aix_tech@yahoo.com] wrote:

I installed Eclipse and the ruby plug-in for it.
However, I don’t see anyway to use it and create
widgets.
Do anyone outthere have any sample code or any
instructions on how to use Eclipse and ruby

together?

At this point the Ruby Eclipse plugin only allows the
editing/running/debugging of Ruby code; unfortunately,
there is no ability
to script Eclipse itself using Ruby.

Nathaniel

<:((><


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Take a look at

-r.

David Corbin wrote:

···

Now there’s a good idea. Elsewhere I suggested the ability to call
Perl modules from Ruby. It would be just as great to be able to call
Java from Ruby. Java has pretty good reflection, so it shouldn’t be
too hard to build dynamic wrappers for Java objects…

I think Mauricio Fernandez is working on a bridge beetween ruby and
java via JNI, take a look at
http://thekode.net/ruby/rjni/
even if it’s still alpha, seems really interesting to me

···

il Tue, 26 Aug 2003 22:01:51 +0900, David Corbin dcorbin@machturtle.com ha scritto::

Now there’s a good idea. Elsewhere I suggested the ability to call
Perl modules from Ruby. It would be just as great to be able to call
Java from Ruby. Java has pretty good reflection, so it shouldn’t be too
hard to build dynamic wrappers for Java objects…

I’m now re-implementing the stuff in C to make it faster.

···

On Wed, Aug 27, 2003 at 04:28:31AM +0900, gabriele renzi wrote:

il Tue, 26 Aug 2003 22:01:51 +0900, David Corbin > dcorbin@machturtle.com ha scritto::

Now there’s a good idea. Elsewhere I suggested the ability to call
Perl modules from Ruby. It would be just as great to be able to call
Java from Ruby. Java has pretty good reflection, so it shouldn’t be too
hard to build dynamic wrappers for Java objects…
I think Mauricio Fernandez is working on a bridge beetween ruby and
java via JNI, take a look at
http://thekode.net/ruby/rjni/
even if it’s still alpha, seems really interesting to me


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Problem solving under Linux has never been the circus that it is under
AIX.
– Pete Ehlke in comp.unix.aix

I am not sure what the AIX comment is all about, but
my experience with the different versions of UNIX, is
that AIX is perhaps the most estable version of UNIX

···

on the field today. It is also very simple to administer. — Mauricio Fernández batsman.geo@yahoo.com wrote:

On Wed, Aug 27, 2003 at 04:28:31AM +0900, gabriele > renzi wrote:

il Tue, 26 Aug 2003 22:01:51 +0900, David Corbin > > dcorbin@machturtle.com ha scritto::

Now there’s a good idea. Elsewhere I
suggested the ability to call
Perl modules from Ruby. It would be just as
great to be able to call
Java from Ruby. Java has pretty good reflection,
so it shouldn’t be too
hard to build dynamic wrappers for Java
objects…
I think Mauricio Fernandez is working on a bridge
beetween ruby and
java via JNI, take a look at
http://thekode.net/ruby/rjni/
even if it’s still alpha, seems really interesting
to me

I’m now re-implementing the stuff in C to make it
faster.


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Problem solving under Linux has never been the
circus that it is under
AIX.
– Pete Ehlke in comp.unix.aix
is under
AIX.
– Pete Ehlke in comp.unix.aix


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

What do you mean by “estable”? I’m not familiar with the term.

···

— Ludwigi Beethoven aix_tech@yahoo.com wrote:

I am not sure what the AIX comment is all about, but
my experience with the different versions of UNIX, is
that AIX is perhaps the most estable version of UNIX
on the field today. It is also very simple to
administer.


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Michael Campbell wrote:

···

— Ludwigi Beethoven aix_tech@yahoo.com wrote:

I am not sure what the AIX comment is all about, but
my experience with the different versions of UNIX, is
that AIX is perhaps the most estable version of UNIX
on the field today. It is also very simple to
administer.

What do you mean by “estable”? I’m not familiar with the term.

I assumed it was a typofor “stable.”

Hal

It’s probably just the word “Stable”. I would guess that Ludwigi
entered a typo.

Scott

···

— Ludwigi Beethoven aix_tech@yahoo.com wrote:

I am not sure what the AIX comment is all about, but
my experience with the different versions of UNIX, is
that AIX is perhaps the most estable version of UNIX
on the field today. It is also very simple to
administer.

What do you mean by “estable”? I’m not familiar with the term.

I am not sure what the AIX comment is all about, but
my experience with the different versions of UNIX, is
that AIX is perhaps the most estable version of UNIX
on the field today. It is also very simple to
administer.

What do you mean by “estable”? I’m not familiar with the term.

I assumed it was a typofor “stable.”

<D’oh!> Of course. chuckle… thanks. =)

(I must have my “Friday brain” on today…)

···

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Well, since I am just a neophyte on the subject, I can
only speak for myself. I define “estable” an
environment that is available when I need it. Where I
work we have AIX, HP, Solaris, Linux. AIX is always
available.

···

— Hal Fulton hal9000@hypermetrics.com wrote:

Michael Campbell wrote:

— Ludwigi Beethoven aix_tech@yahoo.com wrote:

I am not sure what the AIX comment is all about,
but
my experience with the different versions of UNIX,
is
that AIX is perhaps the most estable version of
UNIX
on the field today. It is also very simple to
administer.

What do you mean by “estable”? I’m not familiar
with the term.

I assumed it was a typofor “stable.”

Hal


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Obviously it was a typographical error. But I was so
much into the meaning of the stmt that I did not see
through the sarcasm of others. Oh well, that’s what
happens when you are naïve. However, I will be willing
to bet that most of the responder can ONLY speak one
and no more than one natural language, English. Those
are most of the time called North American.

sta·ble1 - adj. sta·bler, sta·blest
a. Resistant to change of position or condition; not
easily moved or disturbed: a house built on stable
ground; a stable platform.

···

— Scott Thompson easco@mac.com wrote:

— Ludwigi Beethoven aix_tech@yahoo.com wrote:

I am not sure what the AIX comment is all about,
but
my experience with the different versions of
UNIX, is
that AIX is perhaps the most estable version of
UNIX
on the field today. It is also very simple to
administer.

What do you mean by “estable”? I’m not familiar
with the term.

It’s probably just the word “Stable”. I would guess
that Ludwigi
entered a typo.

Scott


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Michael Campbell wrote:

I am not sure what the AIX comment is all about, but
my experience with the different versions of UNIX, is
that AIX is perhaps the most estable version of UNIX
on the field today. It is also very simple to
administer.

What do you mean by “estable”? I’m not familiar with the term.

I assumed it was a typofor “stable.”

<D’oh!> Of course. chuckle… thanks. =)

(I must have my “Friday brain” on today…)

:slight_smile:

It does look like “nestable” with a missing n.

Actually after reading my own post, I thought it
would be funny if you said, “I don’t know the
word ‘typofor’ – what does that mean?” :slight_smile:

Hal

Obviously it was a typographical error. But I was so
much into the meaning of the stmt that I did not see
through the sarcasm of others. Oh well, that’s what
happens when you are naïve.

I was not being sarcastic; I honestly didn’t see the “obvious” typo, or I would
not have asked.

However, I will be willing
to bet that most of the responder can ONLY speak one
and no more than one natural language, English. Those
are most of the time called North American.

Is this in any way relevant, or just an easy “slam” on North Americans? Some
equally unflattering (and likely equally untrue) generalities may be made about
Europeans.

Ludwigi Beethoven wrote:

Obviously it was a typographical error. But I was so
much into the meaning of the stmt that I did not see
through the sarcasm of others. Oh well, that’s what
happens when you are nai"ve.

I honestly don’t know what sarcasm you’re talking
about.

Hal

<D’oh!> Of course. chuckle… thanks. =)

(I must have my “Friday brain” on today…)

:slight_smile:

It does look like “nestable” with a missing n.

Actually after reading my own post, I thought it
would be funny if you said, “I don’t know the
word ‘typofor’ – what does that mean?” :slight_smile:

hah, I considered that, but it was almost too easy.

···

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

I must admit that your reply was/is funny.

···

— Hal Fulton hal9000@hypermetrics.com wrote:

Michael Campbell wrote:

I am not sure what the AIX comment is all about,
but
my experience with the different versions of
UNIX, is
that AIX is perhaps the most estable version of
UNIX
on the field today. It is also very simple to
administer.

What do you mean by “estable”? I’m not familiar
with the term.

I assumed it was a typofor “stable.”

<D’oh!> Of course. chuckle… thanks. =)

(I must have my “Friday brain” on today…)

:slight_smile:

It does look like “nestable” with a missing n.

Actually after reading my own post, I thought it
would be funny if you said, “I don’t know the
word ‘typofor’ – what does that mean?” :slight_smile:

Hal


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com