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 =>
"subdivisions.position"
....
end
class Subdivision < ActiveRecord::Base
belongs_to :member
belongs_to :application_partial, :dependent => :destroy
acts_as_list :scope => :member_id
end
class ApplicationPartial < ActiveRecord::Base
has_many :subdivisions
has_many :members, :through => :subdivisions
end
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.
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.
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
this?