27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

This chapter covers<br />

� Building a basic Rack application<br />

� Tying together Rack applications<br />

� Mounting a Rack app within a Rails app<br />

Rack-based applications<br />

� Using Rack middleware to alter server response<br />

So far, this book has primarily focused on how to work with pieces of the Rails<br />

framework, such as application and engines. In this chapter, we’ll look at how you<br />

can use Rack-based applications to respond more quickly than what you’d otherwise<br />

be capable of with your main application.<br />

Rack is the underlying web server framework that powers the underlying<br />

request/response cycle found in Rails, but it isn’t a part of Rails itself. It’s completely<br />

separate, with Rails requiring the parts of Rack it needs. When your application<br />

is running, it’s running through a web server. When your web server receives a<br />

request, it will pass it off to Rack, as shown in figure 18.1.<br />

Rack then determines where to route this request, and in this case it has chosen<br />

to route to a specific application stack. The request passes through a series of<br />

pieces called middleware (covered in the final section of this chapter) before arriving<br />

at the application itself. The application will then generate a response and pass<br />

516

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!