jeudi 14 avril 2016

When does an after_create get fired in rails?

I am reading the docs and they this above the AR lifecycle hooks:

Callbacks are hooks into the life cycle of an Active Record object that allow you to trigger logic before or after an alteration of the object state. This can be used to make sure that associated and dependent objects are deleted when destroy is called (by overwriting before_destroy) or to massage attributes before they're validated (by overwriting before_validation). As an example of the callbacks initiated, consider the Base#save call for a new record:

(-) save

(-) valid

(1) before_validation

(-) validate

(2) after_validation

(3) before_save

(4) before_create

(-) create

(5) after_create

(6) after_save

(7) after_commit

So does this mean an after_create hook gets called after these calls:

.save
.create
.valid

Aucun commentaire:

Enregistrer un commentaire