# Form handling using ruby

**URL:** <https://www.ruby-forum.com/t/form-handling-using-ruby/106792>\
**Category:** Ruby\
**Created:** [June 14, 2007, 5:12am UTC](https://www.ruby-forum.com/t/form-handling-using-ruby/106792 "2007-06-14T05:12:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [June 14, 2007, 5:12am UTC](https://www.ruby-forum.com/t/form-handling-using-ruby/106792/1 "2007-06-14T05:12:36Z")

</div>

Hi,

I’m a newbie to ruby and web programming. I created a very simple html  
form and set the action to “action=actionhandler.rb”, after following an  
example from a book. But when I click submit, instead of running  
actionhandler.rb, my browser shows the source code of actionhandler.rb.  
I’m running these things on Apache webserver. So where am I going wrong  
? Do I need any additional plugins ? Any help would be greatly  
appreciated.

My actionhandler.rb file looks as follows:

#!/usr/local/ruby/bin/ruby

require ‘cgi’  
cgi = CGI.new

puts cgi[‘name’]  
puts cgi[‘reason’]

f= File.new(“output”,“w”)

f.puts cgi[‘name’]  
f.puts cgi[‘reason’]

f.close

Thanks,  
Mark

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [June 14, 2007, 3:56pm UTC](https://www.ruby-forum.com/t/form-handling-using-ruby/106792/2 "2007-06-14T15:56:39Z")

</div>

On Jun 13, 2007, at 10:12 PM, Mark wrote:

> ? Do I need any additional plugins ? Any help would be greatly  
> puts cgi[‘reason’]
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Hey Mark,  
Any time you do this, you need to set the permissions on the file, so  
that it is executable.  
But the symptom you are having is more often caused by the fact that  
Apache doesn’t know what to do with a file of the extension .rb now.  
You need to make sure it has mod\_ruby or something.  
In your web directory you should have a .htaccess file in which you  
can write some Apache directives.  
Google some of these and check the FAQ/support on your web server.
