tags:

views:

623

answers:

3

I don't get it!

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

Rails Metal: http://weblog.rubyonrails.org/2008/12/17/introducing-rails-metal

I read the two articles and my eyes got blurry. How do the two components relate? Examples would be great?

+2  A: 

Rack is a generic Ruby API/layer of abstraction that lets different application frameworks integrate to a web server.

Rails Metal is Rails's implementation of a Rack handler. It includes not only a handler that calls Rails but also exposes its own API that makes it easier for you to create your own handlers that hit the web server and bypass core Rails.

Wayne Kao
+9  A: 

Rack is a very lightweight specification that Ruby web servers can implement. It's middleware which means that it sits in between the web server (e.g. Passenger) and Rails.

Rails Metal is a way of processing an HTTP request using Rails for when you need the maximum performance. It literally takes you down to the metal and bypasses all the normal features (and thus overhead) that the standard Rails' request/response cycle gives you. Technically, Rails Metal is an implementation of a Rack handler.

You might find these two Railscasts on the subject informative:

You can get a listing of the Rack middleware stack for a Rails application using rake middleware

John Topley
+3  A: 

There's a great discussion and a few examples on Jesse Newland's site:

So, essentially, Rails Metal is a thin wrapper around Rails’ new Rack middleware support. Rack middleware is pretty powerful stuff: framework-independent components that process requests independently or in concert with other middleware.

brism