On Jul 19, 2012, at 5:10 AM, tomkins wrote:
> Hi,
>
> I currently have a page with a table-plus of companies, each of which can have many contacts. All contacts are listed on another page in another table.
> If I delete a company the contacts don't get deleted, they are left with null value for their company attribute.
> They are connected in my sqlite3 database, each contact row has a column with companyID.
> How can I delete all the contacts belonging to the company when I press remove company?
You're looking for the :dependent option for has_many:
http://guides.rubyonrails.org/association_basics.html#has_many-dependent
--Matt Jones