# Observers and notification order for associated records

**URL:** <https://www.ruby-forum.com/t/observers-and-notification-order-for-associated-records/136787>\
**Category:** Rails\
**Created:** [May 6, 2008, 1:01pm UTC](https://www.ruby-forum.com/t/observers-and-notification-order-for-associated-records/136787 "2008-05-06T13:01:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![christos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e36b37/32.png) [@christos](https://www.ruby-forum.com/u/christos)\
**Post date:** [May 6, 2008, 1:01pm UTC](https://www.ruby-forum.com/t/observers-and-notification-order-for-associated-records/136787/1 "2008-05-06T13:01:26Z")

</div>

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
