Reputation: 1540
I was able to find the order the callbacks are kicked off here but it does not say if it is dynamic (if self.errors.any? stop callback chain). Does anyone know if before_create is called only if all validations are passed? Or have any links for in depth walk through on this process.
Upvotes: 1
Views: 505
Reputation: 62648
Your initial hunch is correct. before_create
is only called if validations pass. This is easily observed in your original link by looking at the callback lifecycle:
before_validation
. <----- validations happen here
after_validation
before_save
before_create
around_create <--- save happens in here
after_create
after_save
If at any point a callback, validations, or save fail, then the later parts of the validate/save cycle are not run.
Upvotes: 2