From: David Masover Date: 2009-11-26T04:55:37+09:00 Subject: Re: Ruby a good choice for CGI? On Wednesday 25 November 2009 01:12:19 pm Nick Dr wrote: > I've written a small HTML/JQuery page that displays a simple UI on a > canvas element. The user clicks on pictures of buttons and the JQuery > posts a string to the server. I need some server side code - hopefully > ruby b/c i like the syntax, and i've heard bad things about PHP - that > will take the command from the POST, hit a MySQL db, and return a string > response. The JQuery takes the string response and updates the canvas. That sounds tailor-made for Sinatra. However, you should learn something about REST, first -- are you sure POST is appropriate? > I've > already got the Ruby code itself, including the MySQL part. Why MySQL specifically? Why not go with something database-agnostic, like Datamapper, Sequel, or ActiveRecord? But hey, if you've already got it, it works. > I've be told things about > FastCGI, Passenger, mod_ruby, Rack, Sinatra, Camping, etc. and I can't > even figure out which one I need! FastCGI is obsolete, so scratch that. Passenger and mod_ruby are essentially the same thing, IIRC. But my understanding is that Passenger works with Rack, which doesn't feel at all like CGI. So these might be deployment options, but they have nothing to do with how you write and develop your app. So among your options are Sinatra and Camping. Camping is by _why, who seems to have disappeared, but I'm sure someone's maintaining it... What I like about Sinatra is the sheer simplicity of: get '/' do 'Hello, world!' end In your case, assuming you still want a POST, it'll probably be something like: post '/wherever' do # build your string from the database and return it end Once you've got it working on localhost, if you can find a managed host that'll just let you upload a Rack app (especially if they know about Sinatra), do that. Or you could do it yourself -- right now, I'm liking nginx and Unicorn, which is what Github uses: http://github.com/blog/517-unicorn On the other hand, you could technically deploy this with Passenger. Some people find it easier, but I like deploying with Capistrano anyway. > some basic > cookie/session support. http://www.sinatrarb.com/faq.html#sessions > What's the least headache(and not terribly slow) > way to do this? My vote is Sinatra.