After_create caused after unsuccessful save?

I want to send a request for external software when I am sure that the model is saved.

1) How to determine the order in which after_create is called?

2) does it cause a call to the failed creature?

The RAILS API documentation says:

Note that this callback is still wrapped in a transaction around the save.

3) Does this mean that save requires success to be successful before after_save is after_save or does it mean that when the save call is called after_save always fires?

+7
ruby-on-rails activerecord
source share
1 answer

How would I know in what order after_create is called, and if this is saved through a failed creation?

Here you can read the callback order: http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html

If the transaction failed, the save (and create / update ) events return false . This will stop all subsequent callbacks. So, after_save , after_create / after_update all never run when save fails (or create / update fails).

... and the transaction will be rolled back, so the database is not actually updated.

+4
source share

All Articles