Specify callbacks before associations


#1

In the RoR API documentation
(http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html) for
callbacks, there is a note that says:

IMPORTANT: In order for inheritance to work for the callback queues,
you must specify the callbacks before specifying the associations.
Otherwise, you might trigger the loading of a child before the parent
has registered the callbacks and they wonâ??t be inherited.”

Does this mean a model should be defined as:

class NetworkSegment < ActiveRecord::Base
after_create :create_network_ipaddresses
after_update :update_network_ipaddresses

has_many :network_ipaddresses, :order => octet4

#…
end

or

class NetworkSegment < ActiveRecord::Base
has_many :network_ipaddresses, :order => octet4

after_create :create_network_ipaddresses
after_update :update_network_ipaddresses

#…
end

Thanks,
-Jer