Forum: Ruby on Rails Running callbacks in observers before callbacks in models

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
61cb6399bf6fe72babb700641da1ddea?d=identicon&s=25 Brendon (Guest)
on 2008-11-26 05:46
(Received via mailing list)
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
This topic is locked and can not be replied to.