Observers and notification order for associated records; bug or design?

[I asked this in rails-talk a few days ago, but I didn't get an answer. Thinking that the question might be a bit more esoteric, and more appropriate to ask in Core. Apologies if I am off-topic]

Is it by design that the following happens (Rails 2.0.2)?

  @post = Post.find(params[:id])   @post.comments.build(params[:comment])   @post.save

Assuming I have a PostObserver which observes after_update, what happens is:

  1. Transaction BEGINS   2. @post is saved   3. PostObserver#after_update is called   4. Comment is created   5. Transaction COMMITED

As this is a transaction I would expect to get the after_update, AFTER all associated records are created/updated but this is not the case.

-christos

The thing is that in rails, the observers and callback methods are called after the object is updated, but they do not consider assotiated objects update as object update.

if you modify the post in the comment creation then it would be a Post update and the observer would be called …