From the course: Ruby on Rails 6 Essential Training: Models and Associations

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Overview of callbacks

Overview of callbacks - Ruby on Rails Tutorial

From the course: Ruby on Rails 6 Essential Training: Models and Associations

Start my 1-month free trial

Overview of callbacks

- [Instructor] In this chapter, we're going to be learning about another feature on active record known as callbacks. And we'll start by getting an overview. Callbacks are a way that ActiveRecord gives us to intervene in an object's life cycle. It's almost like it pauses before or after key moments in its internal processes, to check in with you to see if you have code customization that you'd like to run before it continues. It allows you then to run code automatically before or after an object is created, updated or destroyed. Sometimes callbacks are also referred to as code hooks. Because they give us an opportunity to hook in our code. Let's take a look at a chart that I think will help to explain how they work. This chart has three different columns create, update, and destroy. For each one of these columns you're going to read down to see the points in the objects lifecycle where we can intervene. Let's start by…

Contents