LibraryActive

Active Storage Overview

Active Storage Overview: Ruby on Rails Guides (v8.1.3.1) These are the new guides for Rails 8.1 based on v8.1.3.1 .

Open source page

Field note

What it does

Active Record Callbacks This guide teaches you how to hook into the life cycle of your Active Record objects. After reading this guide, you will know: When certain events occur during the life of an Active Record object. How to register, run, and skip callbacks that respond to these events. How to create relational, association, conditional, and transactional callbacks. How to create objects that encapsulate common behavior for your callbacks to be reused. Skip to article body Chapters The Object Life Cycle Callback Registration Registering Callbacks to Fire on Life Cycle Events Available Callbacks Creating an Object Updating an Object Destroying an Object after_initialize and after_find after_touch Running Callbacks Conditional Callbacks Using :if and :unless with a Symbol Using :if and :unless with a Proc Multiple Callback Conditions Using Both :if and :unless Skipping Callbacks Suppressing Saving Halting Execution Association Callbacks Cascading Association Callbacks Transaction Callbacks after_commit and after_rollback Aliases for after_commit Transactional Callback Ordering Per transaction callback ActiveRecord.after_all_transactions_commit Callback Objects 1. The Object Life Cycle During the normal operation of a Rails application, objects may be created, updated, and destroyed . Active Record provides hooks into this object life cycle so that you can control your application and its data.

Capabilities

Available capabilities

Tags

Tags

No tags filed yet.

Ways to use it

Ways to use it

No integrations filed yet.

Product features

Product features

1. The Object Life Cycle

2.1. Registering Callbacks to Fire on Life Cycle Events

2. Callback Registration

3.1.1. Validation Callbacks

3.1.2. Save Callbacks

3.1.3. Create Callbacks

3.1. Creating an Object

3.2.1. Update Callbacks

3.2. Updating an Object

3. Available Callbacks

Active Record Callbacks

Chapters