After_destroy callback order in Rails3.1.3

I am using PostgreSql as database and Rails 3.1.3 and ruby 1.9.3
I have 3 models.

  • Activity
  • ActivityObject
  • ActivityObjectActivity

They are related this way.


has_many :activity_object_activities,:dependent => :destroy
has_many :activity_objects, :through => :activity_object_activities
after_destroy :do_something_on_activity_object_related


has_many :activity_object_activities, :dependent => :destroy
has_many :activities, :through => :activity_object_activities


belongs_to :activity, :dependent => :destroy
belongs_to :activity_object

When I do a destroy on an activity, what I observe is , the
activity_object_activities table entry is getting deleted before the
call of “do_something_on_activity_object_related” due to “dependent:
So because of this, when the “do_something_on_activity_object_related”
method is called when the activity is destroyed ,it is not able to find
out the activity_object associated with the activity.

Is there a method by which I can call this
“do_something_on_activity_object_related” before the associations
related with the activity are destroyed.
Is there any way I can change the order of the after_destroy callbacks.

Thanks In Advance.