Andrew Kaspick wrote:
I'm having a problem understanding why rails calls the 'before_destroy'
methods in the ordering as as follows (w/contrived ex)...
has_many :users, :dependent => :destroy
If I call destroy on the group...
The ordering of operations is...
before_destroy is called for every user in the group first
before_destroy is called for the group
The order is driven by the relationships you've specified. The :dependent => destroy on Group tells Rails to destroy any User child records *before* trying to destroy User records. That's a basic referential integrity constraint.