I have a "Dependant destroy" and it wont work as its reference is not standard . By this I mean that I have changed the XXX_id to be something else as I had clashes: ambiguous relationships.
class Product < ActiveRecord::Base belongs_to :company has_many :allocations, :dependent => :destroy has_many :companies, :through => :allocations
class Company < ActiveRecord::Base has_many :products, :dependent => :destroy has_many :allocations, :dependent => :destroy has_many :allocated_products, :through => :allocations
And the joining table with an extra field class Allocation < ActiveRecord::Base belongs_to :company belongs_to :allocated_product, :class_name => 'Product' end
I realize the error I get when testing deleting a company is due to the fact that its looking to delete product_id from the allocations table but cannot find it.
"Mysql::Error: Unknown column 'allocations.product_id' in 'where clause': SELECT * FROM `allocations` WHERE (`allocations`.product_id = 3)"
I have looked for options on the call but cant see any suitable Can I best do this by using an after delete filter, and how?