我有5个模型。Server
, Platform
, Game
, RetentionReport
, DataReport
. 我正在尝试使用:dependent => :delete_all
,但它不会工作。这是我的模型。
class Game < ActiveRecord::Base
attr_accessible :name
has_many :platforms, :dependent => :delete_all
end
class Platform < ActiveRecord::Base
attr_accessible :name, :game_id, :company_id
belongs_to :game
has_many :servers, :dependent => :delete_all
end
class Server < ActiveRecord::Base
attr_accessible :name, :region, :device_type, :platform_id, :platform_server_id
belongs_to :platform
has_many :gm_data_reports, :dependent => :delete_all
has_many :gm_retention_reports, :dependent => :delete_all
delegate :company_id, :to => :platform
validates :platform_server_id, :uniqueness => {:scope => :platform_id}
end
class DataReport < ActiveRecord::Base
belongs_to :server
end
class RetentionReport < ActiveRecord::Base
belongs_to :server
end
每当我Game.delete_all
在终端中运行时,都不会删除任何内容,甚至Platforms