On Feb 19, 2011, at 11:09 PM, Solas wrote: > > if a model A has_many :bee, :through => :c, :dependent => :destroy > ... > a.destroy properly cleans up all the bee's ... > > however. > If one does this: > > a.bees = [] > c records are destroyed... bees are untouched. > > This is misleading to me, as: while I can understand semantics that > just the "array" has been modified... > something like :dependent => :destroy should be invariant (the > dependents should be destroyed, under all cases where... the object is > a dependent) > > I am new to this list, so: how does one file a ticket?
rails.lighthouseapp.com is where to file a ticket. However, I don't think this is a bug - :dependent => :destroy only specifies what happens when the object that declares the association gets destroyed - in your second case, you're not destroying 'a'. If you *really* want this behavior, you can probably get it with :dependent => :destroy on the association in model 'C', but the resulting behavior will make *lots* of records vanish that you might not have intended. For instance, here's a simple set of associations: class Project < AR::Base has_many :task_assignments, :dependent => :destroy # 1 has_many :users, :through => :task_assignments end class TaskAssignment < AR::Base belongs_to :project, :dependent => :destroy #3 belongs_to :user end class User < AR::Base has_many :task_assignments, :dependent => :destroy # 2 has_many :projects, :through => :task_assignments end the lines labelled #1 and #2 above are typically a good idea, as they ensure that join records referencing an object are cleaned up when the object is destroyed. #3, on the other hand, means that deleting a user will delete every Project that user was assigned to, as will doing 'user.projects = []'... --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
