2014-10-19 25 views
0

我有4款車型,讓我們說,他們設置與此類似:刪除Ruby on Rails中的所有關聯

first model: 
has_many :this 

second model: 
belongs_to first_model 
has_many :these 

third_model: 
belongs_to second_model 
has_many :more_of_these 

fourth_model: 
belongs_to third_model 

我會把它想,如果有人刪除一些屬於第二模型,其中,那麼它從第三個和第四個刪除它的所有關聯。與第一個模型相同(刪除與模型2,3和4關聯的所有內容)等。

有人能指引我朝着正確的方向嗎?

回答