ActiveRecord and cascade removing


#1

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?


#2

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


#3

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 (


#4

Ok. I got:

class Banner…
has_many :ad_bindings, :dependent => :destroy
end