Executing ruby scripts in browser

I wanted to load my Ruby scripts in the browser, i.d. http://domain.org/foo.rb, but I got a bunch of “Premature end of script headers” errors and I ended up using Eruby instead. ( Not to mention the htaccess headache and the endless combinations of the shebang line I tried before realizing I should check the Apache error log, but that is my stubborn mistake. )

Has anyone managed to get this working? I’m tired of typing ‘
’ at the end of every “puts”.

Thanks a lot.

I have not even gotten this far. How did you get you scripts to execute? I can’t seem to find the right shebang. My browser just shows the raw code.

You can get rid of the need for an empty puts “” by forcing the HTML header.

We are going to use erubis for templating rather than ERB

require ‘erb’

#CGI is needed for headers. Without it the the output may default to plain text
require ‘cgi’

set a new object

cgi = CGI.new(“html3”)

print header type

print cgi.header(“type”=>“text/html”)

should work.