Has_many :through with :dependent = :destroy_all


I have a member class that has many application_partials through
subdivisions. My models look like the following:

class Member < Company

has_many :subdivisions, :dependent => :destroy
has_many :application_partials, :through => :subdivisions, :order =>


class Subdivision < ActiveRecord::Base
belongs_to :member
belongs_to :application_partial, :dependent => :destroy
acts_as_list :scope => :member_id

class ApplicationPartial < ActiveRecord::Base
has_many :subdivisions
has_many :members, :through => :subdivisions

When I destroy a member, all of the application partials associated
with the member should be destroyed as well. I have tried various
methods, but can not find a way to accomplish this.

Thanks for your help!

I think since your ApplicationPartial doesn’t belong_to the Subdivision,
it isn’t a dependent… you might want to revisit how your model
relationships are spec’ed.

Thanks for the reply.

Do you have any recommendations on how this associations should be
done? What I am trying to accomplish is to have a member, that has
and belongs to many ApplicationPartials but using the join table
subdivisions (using has_many :through). Every example that I can find
online does the relationships this way.

Maybe the best was is to write a before destroy action to accomplish

Thanks again!

The more I think about this, the more that it doesn’t make sense, and
is over complicated for what I am trying to do.

I am switching my association to a has_many. Thanks for your help!