From: Brian Candler Date: 2009-03-08T05:26:30+09:00 Subject: Re: CGI newbie Thanks Listening wrote: >>> I'm going to say Sinatra and Ruby 1.9.1 are probably what you want. >> >> I second that. The HTML form processing is already included. > > Since this was a newbie question about writing CGI apps with ruby: If > I'm not mistaken Sinatra is supposed to work as CGI script via rack -- > at least that's what the blurb says. Does anyone happen to know a > Sinatra newbie + rack for CGI tutorial? The last time I tried I didn't > get the impression this was something anyone has ever tried to do > before. Is it possible? Is it useful? I tried it. It works, but: - you need the most recent Sinatra (0.9.1) - you need rack HEAD from git - you need to add set :server,"cgi" since CGI isn't (yet) autodetected - you need to beware that your links are relative to your CGI, so instead of %form{:action=>"/update", ...} you need %form{:action=>"/cgi-bin/first-sinatra.rb/update", ...} This is where having a link helper method which prepends env["SCRIPT_NAME"] is useful. - startup time can be improved by removing 'require "rubygems"' and explicitly adding paths: $:.unshift "/path/to/sinatra/lib" $:.unshift "/path/to/rack/lib" $:.unshift "/path/to/haml/lib" -- Posted via http://www.ruby-forum.com/.