When Rails abstractions are not enough
The Ruby on Rails framework revolutionized web development with its convention-over-configuration principle and MVC pattern. But as applications grow, that initial simplicity often leads to complexity, making a well-structured codebase difficult to maintain.
This book helps you get the most out of Rails while keeping your code clean and maintainable through useful patterns and abstraction layers.
What’s new in the second edition
The second edition came out in December 2025. It keeps the techniques from the first edition and adds two topics that reflect today’s Rails development:
- State transitions and workflows: identify implicit state machines, make them explicit, and isolate them for clarity and resilience
- Abstractions in the AI era: treat LLMs as APIs, extract agent layers, and use third-party libraries and RAG strategies to keep AI features organized and testable
What’s inside
Core concepts
- Rails’ architectural patterns with their advantages and disadvantages
- Rails anti-patterns and how to refactor them
- Organizing business logic when the default approach is insufficient
- Introducing new abstractions to address design problems
Practical patterns covered
- Data layer abstractions: beyond Active Record
- State transitions and workflows: from implicit to explicit state machines
- Handling user input: outside of models
- Representation layer: pulling out view logic
- Authorization models: multiple layers and approaches
- Notifications layer: from mailers to multi-channel deliveries
- HTML views: better abstractions for complex UIs
- AI integrations: LLMs as APIs, agent layers, and context management
Who this book is for
Whether you’re growing an MVP into a production system, scaling a monolithic app, or adding AI-driven features, this book provides battle-tested patterns from Evil Martians’ extensive experience building and scaling Rails applications for startups and enterprises.
Prerequisites
- Deep understanding of core Rails principles
- Prior experience building web apps with Rails
- Desire to write maintainable, scalable code
About the author
Vladimir Dementyev is a backend engineer at Evil Martians, award-winning contributor to Ruby on Rails and Ruby, creator of AnyCable, TestProf, Action Policy, and dozens of other open source projects. He’s been solving Rails architectural challenges for over a decade, working with startups and established companies worldwide.
Get the book
Available in print, Kindle, and PDF formats:
- Amazon—Print and Kindle editions
- Packt Publishing—All formats including PDF
“This book will help you keep your code maintainable while working on a Rails app… By the end of this book, you’ll become a code design specialist with a deep understanding of the Rails framework principles.”