GOAL: To install the Rack gem so Puma can talk to our web application.

All Ruby-based application servers (like Puma) and web applications follow the Rack specification.

What is Rack?

Rack provides a simple interface that allows Ruby-based web frameworks and application servers communicate with each other. The Rack specification has two conditions:

  1. The application should have a call method that takes an env object representing the incoming HTTP request.
  2. The application should return an array containing the status, headers, and response.

So that is Rack, a specification. However, in addition to being an abstract protocol, Rack is also a gem. It provides a bunch of useful tools, such as middleware and a convenient DSL (domain-specific language) to run rack-compliant web applications.

Let's install the Rack gem using Bundler.

$ bundle add rack

If you want to learn about Rack in depth right now (both the specification as well as the gem), I suggest you read this article on my blog: The Definitive Guide to Rack for Rails Developers.

In the next lesson, we'll create an application Puma will talk to using the Rack specification.

Let's install the Rack gem using Bundler.