# Running callbacks in observers before callbacks in models

**URL:** <https://www.ruby-forum.com/t/running-callbacks-in-observers-before-callbacks-in-models/154179>\
**Category:** Rails\
**Created:** [November 26, 2008, 5:46am UTC](https://www.ruby-forum.com/t/running-callbacks-in-observers-before-callbacks-in-models/154179 "2008-11-26T05:46:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brendon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f9b8f/32.png) [@brendon](https://www.ruby-forum.com/u/brendon)\
**Post date:** [November 26, 2008, 5:46am UTC](https://www.ruby-forum.com/t/running-callbacks-in-observers-before-callbacks-in-models/154179/1 "2008-11-26T05:46:24Z")

</div>

Hi there, I’ve noticed a switch in behaviour between Rails 2.2.2 and  
older versions. I have a polymorphic tree structure in my CMS. So when  
a person creates a Page, I have an observer watching the Page model,  
after a page is created, the observer creates a record in the  
ComponentInstance table (the central tree model). The problem is that  
I need this relationship to exist for some of my Page callbacks to  
work. E.g. I want to create some children off this compoent instance  
straight away. page.component\_instance.children.

In old versions of rails the callback in the observer seemed to run  
before the callbacks in the model that was being observed. Now it  
seems to be the reverse and the callbacks in the model get run first  
and expect to see a component instance (Which doesn’t exist yet  
because the observer callback hasn’t been run yet).

Could someone explain to me how to get these callbacks to run in a  
different order?

Cheers,

Brendon
