Hi. Please help me how to make cascade delete for this 3 classes: class Section < ActiveRecord:Base has_many :ad_bindings has_many: banners, :through => :ad_bindings end class AdBinding < ActiveRecord:Base belongs_to :banner end class Banner < ActiveRecord:Base end When I remove Banner, I need to remove AdBinding also, but it still stored in database. Where I wrong?
on 2006-05-13 22:40
on 2006-05-13 23:04
Try belongs_to :banner, :dependent => true This says that the child row cannot exist without the row in the parent table, and will do a cascading delete. Ken
on 2006-05-13 23:20
On Sat, 2006-05-13 at 21:03 +0200, Kenneth L. wrote: > Try > > belongs_to :banner, :dependent => true > > This says that the child row cannot exist without the row in the parent > table, and will do a cascading delete. > > Ken > It's not helpful, I still have rows in 'ad_bindings' table (
on 2006-05-13 23:44
Ok. I got: class Banner... has_many :ad_bindings, :dependent => :destroy end