Relationships and Deleting

I am playing around with relationships at the moment and am hitting a wall.

I have a group.

class Group < ActiveRecord::Base   has_many :contacts end

and a contact.

class Contact < ActiveRecord::Base   belongs_to :group end

If I destroy group it doesn't destroy contacts in the group.

Am I missing something obvious?

Thanks!

To delete contacts when the group is deleted:

   has_many :contacts, :dependent => :destroy

or if you don't use callbacks (before_destroy, after_destroy) in Contact, this is faster:

   has_many :contacts, :dependent => :delete_all

chalkers wrote:

Thanks lx Quic!

Very informative.