A New Architecture For Rails

Written by the creator of Trailblazer, this book gives you 300 pages full of wisdom about Trailblazer and its gems, such as Reform, Cells and Roar.

The book comes with a sample app repository to conveniently browse through changes per chapter.

In the book, we build a realistic Rails application with Trailblazer that discusses convoluted requirements such as dynamic forms, polymorphic rendering and processing for signed-in users, file uploads, pagination, a JSON document API sitting on top of that, and many more problems you run into when building web applications.

Here's an overview of the 13 chapters

In chapter 2, The Trailblazer Architectural Style, we discuss implementation concepts, file structuring and how Trailblazer solves problems from conventional MVC frameworks such as Rails.

The next chapter Operations and Forms will illustrate how Trailblazer introduces a new abstraction layer Operation that embraces the business logic. We learn how to benefit from the operation's internal form object, so that you can start applying this pattern to your existing software.

After learning the basics, we dive into Cells and explore how to use view components in Trailblazer to build a grid-based homepage. The following Nested Forms chapter goes into more details of operations and how they interact with Reform. To round this up, the learnt concepts about view models and forms are combined in the Composed Views chapter.

We then discuss Callbacks and post-processing logic in operations, and how that is a fundamental different approach to the Rails way of doing it.

Chapter 9 and 10 show you how Authentication works in a Trailblazer application, and how Authorization and Polymorphism help to maintain polymorphic operations, forms and views for different user roles.

Having covered all aspects of a real web software, the last two chapters are all about document APIs with Roar. Hypermedia APIs: Rendering discusses the usage of representers from operations and how to serialize JSON documents. But that's only half of the work! Hypermedia APIs: Deserialization will teach you how to use representers for parsing incoming documents and validate them using the operation's form.

If you want to learn about this project and if you feel like supporting Open-Source, please buy and read it and let us know what you think.

Buy it!


"At some point of time we started to decouple our form objects from models. Things got a lot easier when we found out there is a ready to use solution which solves our exact problem. That was Reform. Soon after, we started using all other parts of Trailblazer and haven't regretted a second of our time we spent using it." Igor Pstyga, PeerStreet
"Here at Chefsclub, we are very happy with Trailblazer. Our application already has 32 concepts, 130+ operations, and Cells surprised us as an awesome feature. We feel pretty safe with it." Paulo Fabiano Langer, Chefsclub
"Trailblazer helps organize my code, the book showed me how. You can assume what each component does by its name, it's very easy and intuitive, it should be shipped as an essential part of Rails." Yuri Freire Lima, AzClick
Trailblazer has brought the fun back to Rails for me. It helps me organize large codebases into small, smart, testable chunks. Nick has brought together his years of insight in managing Rails projects and made them available for everyone. Any Rails engineer looking to expand past the default Rails Way should take a look at Trailblazer. Eric Skogen, Software Inventor
I haven't been this excited about Rails since 2007! Trailblazer - makes Rails development fun again. Especially on large projects. It's one of the better implementations of the ServiceObject / ViewModel / Form Object / Policy layers I've seen, which sooner or later ( rather sooner) you'll need. Nick Gorbikoff, Rinica Company