Skip to content

Commit

Permalink
Merge pull request #28670 from aledalgrande/activerecord-docs-fix
Browse files Browse the repository at this point in the history
Fix edge guides for Active Record callbacks
  • Loading branch information
rafaelfranca committed Apr 7, 2017
2 parents 8547d9f + 3820abd commit e88e358
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion guides/source/active_record_callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ Halting Execution

As you start registering new callbacks for your models, they will be queued for execution. This queue will include all your model's validations, the registered callbacks, and the database operation to be executed.

The whole callback chain is wrapped in a transaction. If any _before_ callback method returns exactly `false` or raises an exception, the execution chain gets halted and a ROLLBACK is issued; _after_ callbacks can only accomplish that by raising an exception.
The whole callback chain is wrapped in a transaction. If any callback raises an exception, the execution chain gets halted and a ROLLBACK is issued. To intentionally stop a chain use:

```ruby
throw :abort
```

WARNING. Any exception that is not `ActiveRecord::Rollback` or `ActiveRecord::RecordInvalid` will be re-raised by Rails after the callback chain is halted. Raising an exception other than `ActiveRecord::Rollback` or `ActiveRecord::RecordInvalid` may break code that does not expect methods like `save` and `update_attributes` (which normally try to return `true` or `false`) to raise an exception.

Expand Down

0 comments on commit e88e358

Please sign in to comment.