Sustainable Web Development

with Ruby on Rails

Practical Tips for Building Web Applications that Last

A Book by David Bryant Copeland

Current Status as of Feb 20, 2020 - Updated TOC with the sections for rest of the view plus improved future sectionsView the Table of Contents…

I will be working on this book over the next several months. If you are interested in getting early access, updates, or any other news about this subject, sign up below The mailing list should be low-traffic, but will allow you to review in-development parts of the book and even get a discount when the book goes on sale.


  1. 📝
    Updated TOC with the sections for rest of the view plus improved future sections
  2. 📝
    Updated TOC with the sections for the CSS chapter
  3. 📝
    I'm considering releasing the in-progress book as a beta, in order to get feedback from readers before it's published. Please take the survey. take the survey.
  4. 📕
    Posted a draft of Chapter 1, which outlines the purpose and motivation for the book.
  5. 📝
    Posted a draft Outline
  6. 🚀
    Created the site.

Table of Contents

Got feedback?

  1. Why This Book Exists
    1. What is Sustainability?
    2. Why Care About Sustainability?
    3. How to Value Sustainability?
    4. Assumptions
    5. Opportunity and Carrying Costs
    6. Why should you trust me?
  2. The Rails Application Architecture
    1. Boundaries
    3. Models
    4. Everything Else
    5. The Pros and Cons of the Rails Application Architecture
    6. Where We Go From Here
  3. Setting Up For This Book
    1. What You’ll Need To Follow Along
    2. Setting up Docker for Local Development
  4. Start Your App Off Right
    1. Creating a Rails App
    2. Using The Environment for Runtime Configuration
    3. Configuring Local Development Environment with dotenv
    4. Automating Application Setup with bin/setup
    5. Running the Application Locally with bin/run
    6. Putting Tests and Other Quality Checks in bin/ci
    7. Improving Production Logging with lograge
  5. The View Layer
  6. Routes and URLs
    1. Always Use Canonical Routes that Conform to Rails’ Defaults
    2. Never Configure Routes That Aren’t Being Used
    3. Vanity URLs Should Redirect to a Canonical Route
    4. Don’t Create Custom Actions, Create More Resources
    5. Be Wary of Nested Routes
  7. HTML Templates
    1. Use Semantic HTML
    2. Build Templates Around Their Controller’s Resource as a Single ivar
    3. Think of Partials as Re-usable Components.
    4. Just Use ERB
  8. Helpers
    1. Don’t Conflate Helpers with Your Domain
    2. Helpers Are Best At Markup and Formatting
    3. Presenters, Decorators, and View Models Have Their Own Problems
    4. Use Rails’ APIs to Generate Markup
    5. Helpers Should Be Tested and Thus Testable
  9. CSS
    1. Adopt a Design System
    2. Adopt a CSS Strategy
    3. Create a Living Style Guide to Document Your Design System and CSS Strategy
  10. JavaScript
    1. How and Why JavaScript is a Serious Liability
    2. Embrace Server-Rendered Rails Views
    3. Disable Turbolinks and Remote-Forms-By-Default
  11. App-Like JavaScript
    1. Server-Rendered JavaScript Should Call into Managed JavaScript in Packs
    2. Manage React Code with the react-rails Gem
    3. Libraries Like React Can Be More Complex Than Partial-Based Equivalents
  12. Testing The View
    1. Understand the Value and Cost of Tests
    2. Sustainable System Testing Basics
    3. Sustaining System Tests over Time
    4. Unit Testing JavaScript with Jest
  13. Controllers
    1. Controllers are where HTTP Terminates
    2. Controllers are an Antifragile Layer
    3. Beware Before Actions and Global Variables
    4. Don’t Over Test
  14. Authentication and Authorization
    1. When in Doubt, Use Devise
    2. Authorization and Role-based Access Controls
    3. System Test Access Controls
  15. The Database
    1. Data is More Important Than Your App
    2. Data Modeling Basics
    3. Production-safe Migrations
    4. Data Migration Techniques
    5. Advanced Data Modeling Techniques
    6. Testing Your Schema
  16. Models
    1. ApplicationModel is for Database Access
    2. ActiveModel is for Resource Modeling
  17. Business Logic
  18. Models, Revisited
    1. Embrace SQL
    2. Validations Don’t Provide Data Integrity
    3. Arel will Confuse Everyone—Just Use where
    4. How to (Barely) Use Callbacks
  19. Jobs
    1. Jobs Must Be Idempotent
    2. Understand How Your Job System Works
    3. Safely Modify Job APIs
  20. Other Boundary Classes
    1. Mailers
    2. Mailboxes
    3. Rake Tasks
  21. Operations
    1. Why Observability Matters
    2. Logging is Powerful
    3. Monitor Things You Want To Know About
    4. Managing Unhandled Exceptions
    5. Measure Performance
  22. API Endpoints
    1. A JSON Strategy
    2. Understand How to_json Works
    3. Middleware vs. Before Actions
  23. Scalability Patterns
    1. Database Transactions
    2. Asynchronous Transaction
    3. Sagas / Step Functions
    4. Monoliths, Microservices, and Shared Databases

Email me some feedback