1

Is there a framework for Ruby for CGI that provides similar functionality as Ruby on Rails (mvc)?

Also, The server where the app shall be used on does not support FCGI, only plain old CGI.

3
  • There are many frameworks built on top of Rails. Try Sinatra for example. What's wrong with Rails? Commented Apr 3, 2011 at 5:15
  • @Zepplock I think you meant "built on top of Ruby." Sinatra is separate from Rails. Commented Apr 3, 2011 at 5:25
  • I'd ask this question on ServerFault and/or Pro Webmasters. Commented Apr 3, 2011 at 5:42

1 Answer 1

2

Ruby comes with a CGI module, but it isn't a MVC at all. It makes it easy to extract parameters from a HTTP request passed to the app, encode and decode the query params, etc. It relies on a web server to handle routing the request to the right page, so there's quite a gap between a MVC and a CGI.

There are alternate MVCs for Ruby. Sinatra is very easy to use, and Padrino is built on Sinatra, putting it between Sinatra and Rails. I like using Sinatra at work because it's good for fast prototyping and in-house loads are nowhere close to what we'd get on an internet facing app.

As far as the server not supporting FCGI, a MVC doesn't really care. Put its server on a different port, then reference that port when you want something to talk to Sinatra. For instance, if you tell Sinatra to use 8088, your URLs for Sinatra served pages would be something like: http://host.com:8808/url/path/to/object. Load your Sinatra based app on the web server and start it up. It'll run concurrently with the normal web server.

Sign up to request clarification or add additional context in comments.

5 Comments

But does either Sinatra or Padrino run as CGI? I haven't really seen any CGI examples involving Sinatra yet.
Unfortunately i'm not at liberty to open any additional ports either :(.
@mu thank you for the clarification what "MVC" really means... looks like some people tend to misunderstand it a little bit
The OPs server doesn't support FCGI, only CGI, so it would have to be a very lightweight MVC.
I suppose if the server's default configuration was changed to redirect all connections to a given path to the CGI, the URLs received could be used for REST. Writing a dispatcher isn't hard, and Erubis would be a fast view generator, but loading the models could be expensive. Neither ActiveRecord or Sequel have instantaneous start up times, especially when using models. Maybe fudging on the models and using DBI would be acceptable. Perhaps using Passenger would be acceptable instead, allowing a real MVC?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.