2014-11-14 59 views
0

我有这方面的活动记录模式在我的应用程序麻烦与活动记录模式

class Artist < ActiveRecord::Base 
    has_many :albums, :dependent => :delete_all, autosave: true 
end 

class Album < ActiveRecord::Base 
    attr_accessor :album_artist 
    has_many :tracks, :dependent => :delete_all, autosave: true 
    has_many :covers, :dependent => :delete_all, autosave: true 
    belongs_to :artist 
end 

class Track < ActiveRecord::Base 
    belongs_to :album 
end 

class Cover < ActiveRecord::Base 
    belongs_to :album 
end 

我想,在我的应用程序,当我删除一个艺术家,他的专辑,并在因此,轨道级联和他的专辑封面,全部删除,在一个级联反应。

今天实施的方式,当我删除艺术家,只有相册也被删除,留下孤儿记录在我的数据库。

我做什么不对?

回答