Adam,
Logically speaking, a contact can have multiple addresses, and each
address can have multiple phone numbers:
Contact (master):
has_many :contact_addresses, :dependent => :delete_all
ContactAddress (detail 1):
belongs_to :contact
has_many :addresses_phones, :dependent => :delete_all
has_many :contact_phones, :through => :addresses_phones
ContactPhone (detail 2):
belongs_to :contact_addresses
has_many :addresses_phones, :dependent => :delete_all
has_many :contact_addresses, :through => :addresses_phones
The addresses_phones table (which links addresses and phones) is not in
the model, and simply contains contact_address_id and a contact_phone_id
columns.
I''m wondering if I need to write a line or 2 of code that first deletes
the phone records so that Rails can then delete the address and contact
records.
Here''s the inspiration for all of the above:
http://tinyurl.com/kk5gt
--
Posted via http://www.ruby-forum.com/.