Explore Other Ruby Frameworks

If you made it all the way to the end of this book, you probably have developed some level of fondness for Rails. Nonetheless, you may find that Rails is more than you need, not quite appropriate for the work you want to do, or otherwise annoying. You may even want to supplement your Rails application with something written using a different framework. If you’re interested in exploring further, these are a few of the available options:

Rack (http://rack.rubyforge.org/)

A very minimalist piece of middleware, more of a web server interface, that mostly provides a way to connect servers with other Ruby frameworks. It implements a simple direct connection to HTTP requests, and supports handlers that connect to different web servers, letting you switch servers however seems convenient.

Merb (http://merbivore.com/)

Originally Mongrel plus ERb, Merb started out as a simple tool for supporting file uploads alongside Rails, but developed into a very different framework. Merb provides a few packages for key things, but the basic gem is deliberately minimal. There is an object-relationship manager, but that’s a separate plug-in, as are view helpers, object-relational mappers, etc. Merb builds on Rack. Routing lets you choose different kinds of handling—event handling to optimize for requests that last a short time or threaded server to optimize longer requests.

Merb very deliberately avoids the “magic” of Rails’ naming conventions, which makes it harder to build quickly, but also makes it easier to build exactly what you want and nothing more.

Camping (http://camping.rubyforge.org/)

Camping is a “microframework,” with a core under 4K of code. It’s meant for developing small applications or rapid prototyping. Camping applications are all in one file, which puts some natural limits on size. Intriguingly, multiple Camping applications running on the same server share the same database, which could be cool for connecting the applications or could be disastrous if applications overwrite each other’s data. Output is defined using Markaby, generating HTML from within Ruby block syntax.

Sinatra

A tiny RESTful framework, with minimal dependencies beyond Rack. Sinatra defines routes with simple syntax and return responses.

The common element across all of these is that they are simpler frameworks that do less than Rails. If you feel Rails is doing too much for what you need, these are great tools to explore. You can run them along or in place of Rails, and you can even use some Rails pieces (like ActiveRecord) with them if you’d like.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset