Forum: Ruby Runy newbie question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D81d55649adc28d64e14f3120dafff7d?d=identicon&s=25 Nick (Guest)
on 2007-02-06 13:51
(Received via mailing list)
Dear all,

I'm a newbie at ruby and I have a few simple problems. First I
installed apache and ruby on rails using the guide at
www.apacheguide.org. It appears to work fine.

Now, I have a ruby script that returns an XML file depending on the
input parameters. This script works nicely when run from the windows
command line.

However, I'm puzzled on how to launch it after a user clicks on the
"Submit" button on my website. What happens now, is that IE or FF
wants to download the .rb file.

Do you have any good online examples to share ?

Thank you,

Nick,
4371f8fa1c3574e74d8f88c77d23e7d7?d=identicon&s=25 Harry (Guest)
on 2007-03-01 02:23
(Received via mailing list)
> Now, I have a ruby script that returns an XML file depending on the
> input parameters. This script works nicely when run from the windows
> command line.
>
> However, I'm puzzled on how to launch it after a user clicks on the
> "Submit" button on my website. What happens now, is that IE or FF
> wants to download the .rb file.
>

It works on your computer when you click the submit button but not on
your website when you click submit?

Harry
62002cee15efcf4628cd7efc19425a07?d=identicon&s=25 Tim Becker (Guest)
on 2007-03-01 08:34
(Received via mailing list)
The problem is that your ruby script is also a text file and apache
doesn't know if you'd just like to give back a text file or execute
the script. Per default, it does the safer option, which is just
return the text.
> This script works nicely when run from the windows
> command line.
>
> However, ...  on my website, ... IE or FF
> wants to download the .rb file.

You need to configure the server to  handle cgis. You can either do
this in the global Apache configuration or in a file called
`.htaccess` which alters the configuration for the directory you're
located in. You'll need to require something along the lines of:

  Options +ExecCGI

to instruct the server that execution of cgi's is generally allowed,
and:

   AddHandler cgi-script rb

for Apache to treat .rb files as cgi's. Not sure how this is handled
on Windows, but the script also needs to be executable (chmod +x on
unix).

Sort through the Apache manual, start here:
http://httpd.apache.org/docs/1.3/howto/htaccess.html#cgi

Cheers,
   -tim
This topic is locked and can not be replied to.