O'Reilly logo

Ruby Phrasebook by Jason Clinton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Simple CGI Forms

There are many ways to do CGI with Ruby. For small tasks, I have found that erb/eruby with the cgi module is the simplest, so that’s what I use for the rest of this section. The easiest way to get eruby working is to install mod_ruby (and you get a speed boost, to boot!) After mod_ruby is installed, you need to add some code to your Apache configuration to get it interpreting .rhtml files as eruby files.

<IfModule mod_ruby.c>
    RubyRequire apache/eruby-run

    <Files *.rhtml>
        SetHandler ruby-object
        RubyHandler Apache::ERubyRun.instance
    </Files>
</IfModule>

The preceding code causes Apache to use mod_ruby’s special ERubyRun mode to parse any .rhtml file. .rhtml files are similar to ASP or PHP in that they are normal HTML files ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required