views:

554

answers:

8

For reasons beyond my control, I'm being tasked with Ruby web development that does NOT use Rails or really any other heavyweight framework such as Merb. I'm wondering if anybody else has encountered this and can recommend best practices or resources that describe best practices for such a problem. I'd like to avoid the dreaded

 out.print('<td class="foo">'+some_data+'</td>')

style of web development. A coworker has suggested Rack as a light framework but the documentation is sketchy and it seems unproven in the market.

+12  A: 

Take a look at Sinatra. It's a framework, but not that heavy.

Ionuț G. Stan
Sinatra can handle more load and functionality than some may think at first glance, enough to almost give Rails a run for its money.
The Wicked Flea
Technically, if you bolt on enough crap, a totally blank file can *become* Rails.
Chuck
Which is why you use Sinatra, so it doesn't become that.
The Wicked Flea
A: 

As always good ol' cgi.rb is available.

Peter Stuifzand
If you use cgi.rb consider creating a set of element classes to wrap it.
finnw
A: 

Have you had a look at Sinatra? It is a framework, but not as heavy as Rails. I haven't tested it out myself, but it seems to be very easy to work with.

Also, Ramaze seems to be nice and modular, not sure if it is what you look for though.

I don't know how easy it is to use Ruby directly as a cgi, but it should be quite possible to separate layout from code with that as well. There are quite a few Gems that can do that without using a framework.

Jimmy Stenke
+6  A: 

Look at Rack and Sinatra or Waves. Rack is not unproven in the market. Rails is built on top of rack these days! It also isn't a framework, it allows frameworks to focus on their differentiator rather than the low level busy work.

You can also use jruby and the java servlet api directly. btw, all the rack based frameworks can easily be run on jruby.

jshen
+2  A: 

Rack isn't an application framework so much as a server interface. You will probably want to use it for this project, but it won't solve your problem of wanting a framework without using a framework. At any rate, if you want to "avoid the dreaded out.print('<td class="foo">'+some_data+'</td>')", you're going to have to use a template system at the very least. There are many available, such as ERb (which Rails uses by default) and Haml.

Chuck
A: 

My personal choice and recommendation is Ramaze -- it's as simple as possible, but no simpler. Clean and concise without sacrificing power. Dances well with your choice of JS lib (jQuery, Prototype, Mootools) or ORM (Sequel, Datamapper, M4DBI) or templating engine. Also, don't forget about static generators like nanoc.

Pistos
+1  A: 

Go with Ramaze. I'm using it in production, running on JRuby and Glassfish.

Ease of development, rock-solid community support. No cruft. Like Ruby, it gets out of your way.

James Britt
+1  A: 

I can join in with everyone who's recommend Sinatra. It's compact, a joy to code with, and it deploys on Rack, which means you really get it running in whatever stack you fancy most (Mongrel, FCGI, Thin, Passenger, etc.)

I tried out Sinatra when I needed to get a project up fast and it's scaled & performed so well that I'm still using it today to handle over 80,000 heavy requests a day.

banterability