ActiveRecord and cascade removing

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?

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 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 (

Ok. I got:

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs