Diffeerence between them which I know is that
You almost got it right. However there is one major difference between
In the case of
after_create, this will always be before the call to save (or create) returns.
Rails wraps every save inside a transaction and the before/after create callbacks run inside that transaction (a consequence of this is that if an exception is raised in an after_create the save will be rolled back). With
after_commit, your code doesn't run until after the outermost transaction was committed. This could be the transaction rails created or one created by you (for example if you wanted to make several changes inside a single transaction). Originally posted here
That also means, that if
after_commit raises an exception, then the transaction won't be rolled back.