10

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.

2
  • 1
    What do you mean by "heavyweight"? Commented May 29, 2009 at 22:17
  • Actually, Rails now (as of 2.3) dependends on Rack. Rack is very low level, so that's probably why you don't find the kind of doc you're looking for. But it's a very good piece of software. Commented May 30, 2009 at 0:41

9 Answers 9

17

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

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

3 Comments

Sinatra can handle more load and functionality than some may think at first glance, enough to almost give Rails a run for its money.
Technically, if you bolt on enough crap, a totally blank file can become Rails.
Which is why you use Sinatra, so it doesn't become that.
6

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.

Comments

3

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.

Comments

2

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.

Comments

2

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.

Comments

1

As always good ol' cgi.rb is available.

1 Comment

If you use cgi.rb consider creating a set of element classes to wrap it.
0

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.

Comments

0

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.

Comments

0

It's very possible, my entire website runs on pure ruby.

I haven't encountered any problem. I begin my application with

require "mysql"                               # module | mysql
require "cgi"                                 # module | cgi
require "date"

Comments

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.