Running callbacks in observers before callbacks in models

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?



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