The Rails 6 Way
Minimum price
Suggested price

The Rails 6 Way

About the Book

The book is a pre-release and doesn't contain all chapters yet. Chapters will be released in regular intervals. Below, you can see a table of contents that contains all chapters that have already been released.

“When I read The Rails Way for the first time, I felt like I truly understood Rails for the first time.”—Steve Klabnik, Rails contributor and mentor

The Rails™ 6 Way is the comprehensive, authoritative reference guide for professionals delivering production-quality code using modern Ruby on Rails. It illuminates the entire Rails 6 API, its most powerful idioms, design approaches, and libraries. Building on the previous editions, this edition has been heavily refactored and updated. It features entirely new chapters on Action Mailbox, Action Text, Active Storage, Multi Database Support and Webpacker.

Through detailed code examples, you’ll dive deep into Ruby on Rails, discover why it’s designed as it is, and learn to make it do exactly what you want. Proven in thousands of production systems, the knowledge in this book will maximize your productivity and help you build more successful solutions.

  • Build powerful, scalable, REST-compliant back-end services
  • Program complex program flows using Action Controller
  • Represent models, relationships, and operations in Active Record, and apply advanced Active Record techniques
  • Smoothly evolve your database schema via Migrations
  • Craft front-ends with ActionView
  • Build your assets with the Asset Pipeline and/or Webpacker
  • Optimize performance and scalability with caching and Turbolinks
  • Improve your productivity using Haml HTML templating
  • Secure your systems against attacks like SQL Injection, XSS, and XSRF
  • Integrate email using Action Mailer and Action Mailbox
  • Enable real-time, websockets-based browser behavior with Action Cable
  • Improve responsiveness with background processing
  • Build “API-only” back-end projects that speak JSON
  • Store your files in the cloud via Active Storage
  • Add a great WYSIWYG via Action Text
  • Leverage Multiple Databases

About the Authors

Lucas Dohmen
Lucas Dohmen

Lucas is a senior consultant at INNOQ and works on the architecture, conception and implementation of Web applications on the front and back end. He is programming in Ruby and JavaScript – with Rails being his go to framework for Web applications since 2006. Outside of work he’s doing a lot of open source (such as faucet-pipeline) and community work (like organising and teaching at the local CoderDojo) and records the CaSE podcast, the INNOQ Podcast and more.

Tom Henrik Aadland
Tom Henrik Aadland

Tom Aadland has over 20 years of professional experience in the IT field and has been CTO and one of the founders of Pixelwerk, which was recently acquired by View Software. After the acquisition Tom became the Lead Developer to lead the continuation for the product, called InControl, which they developed in Pixelwerk. InControl is used by several fish farmers across Norway. InControl has been developed in Ruby on Rails, of which Tom was an early adopter and advocate of, specialising in it since 2006. During his spare time he enjoys travelling, reading and music. One of his adventures led him to Argentina Buenos Aires where he spent a decade, pioneering in remote working and living life as a digital nomad before the term was even coined. There he was the founder of the first Rails conference in the Southern Cone, Locos por Rails 2009. When he is not working on some project he spends his time with his wife and two kids.

Obie Fernandez
Obie Fernandez

The "one and only" Obie Fernandez is an avid writer and technology enthusiast, in addition to achieving worldwide success as an electronic music producer and touring DJ. He currently serves as Director and Chief Consultant of MagmaLabs, headquartered in Colima, Mexico.

Obie's last jobby job was SVP of Engineering at NYC tech darling 2U. He has been CTO and co-founder of many startups including Mark Zuckerberg's beloved Andela and Trevor Owen's Lean Startup Machine. His published books include the acclaimed business title The Lean Enterprise. He also founded one of the world's best known Ruby on Rails web design and development agencies, Hashrocket and is author of the bible of Rails development, The Rails Way and series editor for Addison-Wesley's Professional Ruby Series.

On the rare occasion when Obie is not busy building products, consulting clients or writing books, you can find him behind the lens of his camera or DJing in the dust at Burning Man.

Follow @obie on Twitter or email him at 

Table of Contents

  • Foreword
  • Foreword (to The Rails 5 Way)
  • Foreword (to The Rails 4 Way)
  • Foreword (to The Rails 3 Way)
  • Foreword (to The Rails Way)
  • Acknowledgments
  • About the Authors
  • Introduction
    • About This Book
    • David Heinemeier Hansson (aka DHH)
    • Goals
    • Prerequisites
    • Book Structure
    • Licenses, Attributions and Trademark Notice
  • Rails Configuration and Environments
    • Bundler
    • Startup Scripts
    • Default Initializers
    • Other Common Settings
    • The Rails Class Loader
    • Development Mode
    • Test Mode
    • Production Mode
    • Configuring Application Secrets
    • Configuring a Database
    • Logging
    • Default Gems
    • Rack
    • Conclusion
  • Routing
    • The Two Purposes of Routing
    • The routes.rb File
    • Named Routes
    • Scoping Routing Rules
    • Listing Routes
    • Conclusion
  • REST, Resources, and Rails
    • REST in a Rather Small Nutshell
    • Resources and Representations
    • REST in Rails
    • Routing and CRUD
    • The Standard RESTful Controller Actions
    • Singular Resource Routes
    • Nested Resources
    • Routing Concerns
    • RESTful Route Customizations
    • Controller-Only Resources
    • Different Representations of Resources
    • The RESTful Rails Action Set
    • Conclusion
  • Working with Controllers
    • Action Dispatch: Where It All Begins
    • Parameters
    • Render unto View…
    • Additional Layout Options
    • Redirecting
    • Controller/View Communication
    • Action Callbacks
    • Streaming
    • Conclusion
  • Session Management, Cookies and the Flash
    • Cookies
    • Session
    • The Flash
    • What to Store in a Cookie
    • What to Store in the Session
    • Conclusion
  • Action View & Haml
    • Haml
    • Layouts and Templates
    • Partials
    • Conclusion
  • Active Record Migrations
    • Creating Migrations
    • Defining Columns
    • Data Migration
    • Database Schema and Sequencing
    • Database Seeding
    • Database-Related Tasks
    • Conclusion
  • Working with Active Record
    • The Basics
    • Macro-Style Methods
    • Defining Attributes
    • CRUD: Creating, Reading, Updating, Deleting
    • Database Locking
    • Ignoring Columns
    • Connections to Multiple Databases in Different Models
    • Using the Database Connection Directly
    • Convention over Configuration
    • Conclusion
  • Active Record Associations
    • The Association Hierarchy
    • One-to-Many Relationships
    • Belongs to Associations
    • Has Many Associations
    • Many-to-Many Relationships
    • One-to-One Relationships
    • Working with Unsaved Objects and Associations
    • Association Extensions
    • The CollectionProxy Class
    • Conclusion
  • Working with Queries
    • Query Methods
    • Custom SQL Queries
    • Scopes
    • Conclusion
  • Validations
    • Finding Errors
    • Included Validations
    • Common Validation Options
    • Conditional Validation
    • Short-form Validation
    • Custom Validation Techniques
    • Skipping Validations
    • Working with the Errors object
    • Conclusion
  • Advanced Active Record
    • Polymorphic has_many Relationships
    • Modules for Reusing Common Behavior
    • Non-Persisted Models
    • Callbacks
    • Attributes API
    • Serialized Attributes
    • Enums
    • Generating Secure Tokens
    • Calculation Methods
    • Batch Operations
    • Single-Table Inheritance (STI)
    • Abstract Base Model Classes
    • Foreign-key Constraints
    • Value Objects
    • Modifying Active Record Classes at Runtime
    • PostgreSQL
    • Other Connection Methods
    • Conclusion
  • Forms
    • The basics of form_with
    • FormOptionsHelper
    • The Date and Time Selection Helpers
    • Conclusion
  • Internationalization
    • Localized Views
    • I18n Setup
    • Setting and Passing the Locale
    • Setting Locale from Client Supplied Information
    • Internationalizing Your Application
    • Organization of Locale Files
    • Looking Up Translations
    • How to Store Your Custom Translations
    • Exception Handling
    • Conclusion
  • All About Helpers
    • AssetTagHelper
    • AssetUrlHelper
    • AtomFeedHelper
    • CacheHelper
    • CaptureHelper
    • ControllerHelper
    • CspHelper
    • CsrfHelper
    • DateHelper
    • DebugHelper
    • FormHelper, FormOptionsHelper and FormTagHelper
    • JavaScriptHelper
    • NumberHelper
    • OutputSafetyHelper
    • RenderingHelper
    • SanitizeHelper
    • TagHelper
    • TextHelper
    • TranslationHelper
    • UrlHelper
    • Writing Your Own View Helpers
    • Wrapping and Generalizing Partials
    • Conclusion
  • Authentication and Authorization
    • Warden
    • Devise
    • has_secure_password
    • Pundit
    • Conclusion
  • Notes

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Do Well. Do Good.

Authors have earned$10,894,929writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF, EPUB and/or MOBI files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub