user77395
user77395

Reputation:

What's the difference between Rack and Rails Metal (Ruby)?

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?

Upvotes: 6

Views: 4335

Answers (4)

Eric Anderson
Eric Anderson

Reputation: 3792

In addition to the differences covered by other folks, I wanted to note that a Rack app could be either middleware or a final endpoint while ActionController::Metal is always an endpoint an never middleware.

Upvotes: 0

John Topley
John Topley

Reputation: 115422

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 virtually 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

Upvotes: 13

brism
brism

Reputation: 1226

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.

Upvotes: 4

Wayne Kao
Wayne Kao

Reputation: 8285

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.

Upvotes: 4

Related Questions