What are ActiveRecord callbacks?

Answer

ActiveRecord callbacks are hooks that execute code at specific points in an object's lifecycle. Order for save: before_validationafter_validationbefore_savebefore_create/update → (SQL) → after_create/updateafter_saveafter_commit. Useful callbacks: before_save :downcase_email, after_create :send_welcome_email, before_destroy :cancel_subscriptions. Be careful with callbacks — they can make models hard to test and understand. Consider service objects for complex business logic instead.