Is your Ruby on Rails application having growing pains? This book will teach you a simpler way to scale Rails codebases. Instead of introducing new patterns or service-oriented architecture, learn to use discipline, consistency, and code organization to make your application grow more gently. Instead of installing yet another gem, learn to use the tools built into Rails that you already know and love to accomplish your goal.

Distilling more than seven years of work experience with Ruby on Rails, Growing Rails Applications in Practice is packed with actionable techniques that every developer can apply today.

This book was written and produced entirely by the author. We are proud to be distributing it.

Buy Now

Select a DRM-free Format:

In Stock
Buy the eBook and get these DRM-free formats delivered immediately:
  • epub (for iPhone/iPad, Android, eReaders)
  • mobi (for Kindle)
  • PDF
We can automatically send them to your Kindle, and your Dropbox. (You'll need to log in to enable these options.)
 

About this Book

  • 88 pages
  • Published:
  • Release: P2.0 (2014-08-07)
  • ISBN: pending

This book explores low-ceremony techniques to scale large Rails applications. We’ve divided the book into three parts:

In “New Rules for Rails,” we start by unlearning bad Rails habits and introducing design conventions for controllers and user-facing models. By being consistent in our design decisions we can make it easier to navigate and understand our application even as its codebase grows.

In “Creating a System for Growth,” as we implement more and more requirements, all that code has to go somewhere. If all we do is add more lines to existing classes and methods, we end up with an unmaintainable mess. In this part we show how to organize code in a way that encourages the creation of new classes, which in turn enhances comprehensibility and maintainability.

In “Building Applications to Last,” we show how to think about future maintenance when making decisions today. We make a case for adopting new technologies and patterns with care, and for taking full responsibility for those techniques and technologies that we do choose to adopt.

Growing Rails Applications in Practice is packed with actionable techniques every Rails developer can apply. Take back control of your code today!

What You Need

  • Ruby 1.9.3 or higher
  • Rails 3.2 or higher

Contents and Extracts

Introduction
  • How we got here
  • The myth of the infinitely scalable architecture
  • How we structured this book
New rules for Rails
  • Beautiful controllers
    • The case for consistent controller design
    • Normalizing user interactions
    • A better controller implementation
    • Why have controllers at all?
  • Relearning ActiveRecord
    • Understanding the ActiveRecord lifecycle
    • The true API of ActiveRecord models
  • User interactions without a database
    • Writing a better sign in form
    • Building PlainModel
    • Refactoring controllers from hell
Creating a system for growth
  • Dealing with fat models
    • Why models grow fat
    • The case of the missing classes
    • Getting into a habit of organizing
  • A home for interaction-specific code
    • A modest approach to form models
    • More convenience for form models
  • Extracting service objects
    • Example
    • Did we just move code around?
  • Organizing large codebases with namespaces
    • Real-world example
    • Use the same structure everywhere
  • Taming stylesheets
    • How CSS grows out of control
    • An API for your stylesheets
    • The BEM prime directive
    • Full BEM layout example
    • Organizing stylesheets
    • BEM anti-patterns
    • Living style guides
    • Pragmatic BEM
Building applications to last
  • On following fashions
    • Before/after code comparisons
    • Understanding trade-offs
    • The value of consistency
  • Surviving the upgrade pace of Rails
    • Gems increase the cost of upgrades
    • Upgrades are when you pay for monkey patches
    • Don’t live on the bleeding edge
  • Owning your stack
    • Accepting storage services into your stack
    • Maxing out your current toolbox
  • The value of tests
    • Choosing test types effectively
    • How many tests are too many?
    • When to repeat yourself in tests – and when not to
    • Better design guided by tests
    • Getting started with tests in legacy applications
    • Overcoming resistance to testing in your team
  • Closing thoughts

About the Author

Henning Koch is a co-founder and the CTO of makandra, a Ruby on Rails consultancy in Germany. In the rest of the world, makandra is mostly known for Rails LTS, a commercially supported fork of Ruby on Rails. After increasingly failing to stay out of management at makandra, Henning secretly moonlights as a developer for Holly.

Thomas Eisenbarth has spent a decade building and operating things for the Web in multiple languages and frameworks. Thomas is a co-founder and the CEO of makandra. Since 2009 makandra has developed, maintained, and operated a large number of web applications, many of which Thomas has worked on as a lead developer.