Ruby on Rails Guides (v7.2.0)

These are the new guides for Rails 7.2 based on v7.2.0. These guides are designed to make you immediately productive with Rails, and to help you understand how all of the pieces fit together.

The guides for earlier releases: Rails 7.1, Rails 7.0, Rails 6.1, Rails 6.0, Rails 5.2, Rails 5.1, Rails 5.0, Rails 4.2, Rails 4.1, Rails 4.0, Rails 3.2, Rails 3.1, Rails 3.0, and Rails 2.3.


Start Here

Getting Started with Rails

Everything you need to know to install Rails and create your first application.

Models

Active Record Basics

Active Record allows your models to interact with the application's database. This guide will get you started with Active Record models and persistence to the database.

Active Record Migrations

Migrations are a feature of Active Record that allows you to evolve your database schema over time. Rather than write schema modifications in pure SQL, migrations allow you to use a Ruby DSL to describe changes to your tables.

Active Record Validations

Validations are used to ensure that only valid data is saved into your database. This guide teaches you how to validate the state of objects before they go into the database, using Active Record's validations feature.

Active Record Callbacks

Callbacks make it possible to write code that will run whenever an object is created, updated, destroyed, etc. This guide teaches you how to hook into this object life cycle of Active Record objects.

Active Record Associations

In Active Record, an association is a connection between two Active Record models. This guide covers all the associations provided by Active Record.

Active Record Query Interface

Instead of using raw SQL to find database records, Active Record provides better ways to carry out the same operations. This guide covers different ways to retrieve data from the database using Active Record.

Active Model Basics

Active Model allows you to create plain Ruby objects that integrate with Action Pack, but don't need Active Record for database persistence. Active Model also helps build custom ORMs for use outside of the Rails framework. This guide provides you with all you need to get started using Active Model classes.

Views

Action View Overview

Action View is responsible for generating the HTML for web responses. This guide provides an introduction to Action View.

Layouts and Rendering in Rails

This guide covers the basic layout features of Action Controller and Action View, including rendering and redirecting, using content_for blocks, and working with partials.

Action View Helpers

Action View has helpers for handling everything from formatting dates and linking to images, to sanitizing and localizing content. This guide introduces a few of the more common Action View helpers.

Action View Form Helpers

HTML forms can quickly become tedious to write and maintain because of the need to handle form control naming and its numerous attributes. Rails does away with this complexity by providing view helpers for generating form markup.

Controllers

Action Controller Overview

Action Controllers are the core of a web request in Rails. This guide covers how controllers work and how they fit into the request cycle of your application. It includes sessions, filters, cookies, data streaming, and dealing with exceptions raised by a request, among other topics.

Rails Routing from the Outside In

The Rails router recognizes URLs and dispatches them to a controller's action. This guide covers the user-facing features of Rails routing. If you want to understand how to use routing in your own Rails applications, start here.

Other Components

Active Support Core Extensions

Active Support provides Ruby language extensions and utilities. It enriches the Ruby language for the development of Rails applications, and for the development of Ruby on Rails itself.

Action Mailer Basics

This guide provides you with all you need to get started in sending emails from your application, and many internals of Action Mailer.

Action Mailbox Basics

This guide describes how to use Action Mailbox to receive emails.

Action Text Overview

This guide describes how to use Action Text to handle rich text content.

Active Job Basics

Active Job is a framework for declaring background jobs and making them run on a variety of queuing backends. This guide provides you with all you need to get started creating, enqueuing, and executing background jobs.

Active Storage Overview

Active Storage facilitates uploading files to a cloud storage service, transforming uploads and extracting metadata. This guide covers how to attach files to your Active Record models.

Action Cable Overview

Action Cable integrates WebSockets with the rest of your Rails application. It allows for real-time features to be written in Ruby in the same style and form as the rest of your Rails application. This guide explains how Action Cable works, and how to use WebSockets to create real-time features.

Digging Deeper

Rails Internationalization (I18n) API

This guide covers how to add internationalization to your applications. Your application will be able to translate content to different languages, change pluralization rules, use correct date formats for each country, and so on.

Testing Rails Applications

This is a rather comprehensive guide to the various testing facilities in Rails. It covers everything from 'What is a test?' to Integration Testing. Enjoy.

Securing Rails Applications

This guide describes common security problems in web applications and how to avoid them with Rails.

Error Reporting in Rails Applications

This guide introduces ways to manage exceptions that occur in Ruby on Rails applications.

Debugging Rails Applications

This guide describes how to debug Rails applications. It covers the different ways of achieving this and how to understand what is happening "behind the scenes" of your code.

Configuring Rails Applications

This guide covers the basic configuration settings for a Rails application.

The Rails Command Line

There are a few commands that are absolutely critical to your everyday usage of Rails. This guide covers the command line tools provided by Rails.

The Asset Pipeline

The asset pipeline provides a framework to concatenate and minify or compress JavaScript, CSS and image assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass, and ERB.

Working with JavaScript in Rails

This guide explains how to use import maps or jsbundling-rails to include JavaScript in Rails applications, and covers the basics of working with Turbo in Rails.

The Rails Initialization Process
Work in progress

This guide explains the internals of the initialization process in Rails. It is an extremely in-depth guide and recommended for advanced Rails developers.

Autoloading and Reloading

This guide documents how autoloading and reloading constants work.

Migrating from Classic to Zeitwerk

This guide documents how to migrate Rails applications from `classic` to `zeitwerk` mode.

Caching with Rails: An Overview

This guide is an introduction to speeding up your Rails application with caching.

Active Support Instrumentation
Work in progress

This guide explains how to use the instrumentation API inside of Active Support to measure events inside of Rails and other Ruby code.

Using Rails for API-only Applications

This guide explains how to effectively use Rails to develop a JSON API application.

Tuning Performance for Deployment

This guide covers performance and concurrency configuration for deploying your production Ruby on Rails application.

Advanced Active Record

Active Record and PostgreSQL
Work in progress

This guide covers PostgreSQL specific usage of Active Record.

Multiple Databases

This guide covers using multiple databases in your application.

Active Record Encryption
Work in progress

This guide covers encrypting your database information using Active Record.

Composite Primary Keys

This guide is an introduction to composite primary keys for database tables.

Extending Rails

The Basics of Creating Rails Plugins
Work in progress

This guide covers how to build a plugin to extend the functionality of Rails.

Rails on Rack

This guide covers Rails integration with Rack and interfacing with other Rack components.

Creating and Customizing Rails Generators & Templates

This guide covers the process of adding a brand new generator to your extension or providing an alternative to an element of a built-in Rails generator (such as providing alternative test stubs for the scaffold generator).

Getting Started with Engines
Work in progress

Engines can be considered miniature applications that provide additional functionality to their host applications. In this guide you will learn how to create your own engine and integrate it with a host application.

Rails Application Templates
Work in progress

Application templates are simple Ruby files containing DSL for adding gems, initializers, etc. to your freshly created Rails project or an existing Rails project.

Threading and Code Execution in Rails
Work in progress

This guide describes the considerations needed and tools available when working directly with concurrency in a Rails application.

Contributing

Contributing to Ruby on Rails

Rails is not "someone else's framework". This guide covers a variety of ways that you can get involved in the ongoing development of Rails.

API Documentation Guidelines

This guide documents the Ruby on Rails API documentation guidelines.

Guides Guidelines

This guide documents the Ruby on Rails guides guidelines.

Installing Rails Core Development Dependencies

This guide covers how to set up an environment for Ruby on Rails core development.

Policies

Maintenance Policy

What versions of Ruby on Rails are currently supported, and when to expect new versions.

Release Notes

Upgrading Ruby on Rails

This guide provides steps to be followed when you upgrade your applications to a newer version of Ruby on Rails.

Version 7.2 - ?

Release notes for Rails 7.2.

Version 7.1 - October 2023

Release notes for Rails 7.1.

Version 7.0 - December 2021

Release notes for Rails 7.0.

Version 6.1 - December 2020

Release notes for Rails 6.1.

Version 6.0 - August 2019

Release notes for Rails 6.0.

Version 5.2 - April 2018

Release notes for Rails 5.2.

Version 5.1 - April 2017

Release notes for Rails 5.1.

Version 5.0 - June 2016

Release notes for Rails 5.0.

Version 4.2 - December 2014

Release notes for Rails 4.2.

Version 4.1 - April 2014

Release notes for Rails 4.1.

Version 4.0 - June 2013

Release notes for Rails 4.0.

Version 3.2 - January 2012

Release notes for Rails 3.2.

Version 3.1 - August 2011

Release notes for Rails 3.1.

Version 3.0 - August 2010

Release notes for Rails 3.0.

Version 2.3 - March 2009

Release notes for Rails 2.3.

Version 2.2 - November 2008

Release notes for Rails 2.2.


Feedback

You're encouraged to help improve the quality of this guide.

Please contribute if you see any typos or factual errors. To get started, you can read our documentation contributions section.

You may also find incomplete content or stuff that is not up to date. Please do add any missing documentation for main. Make sure to check Edge Guides first to verify if the issues are already fixed or not on the main branch. Check the Ruby on Rails Guides Guidelines for style and conventions.

If for whatever reason you spot something to fix but cannot patch it yourself, please open an issue.

And last but not least, any kind of discussion regarding Ruby on Rails documentation is very welcome on the official Ruby on Rails Forum.