Observers and notification order for associated records

Hi,

Is it by design that the following happens, or is it an ActiveRecord
bug (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.

Has anyone come across this before?

-christos

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs