2
我的關聯選項似乎並未兌現。rails:dependent =>:銷燬被忽略
class ClassRoom < ActiveRecord::Base
has_many :class_assignments, :dependent => :destroy
has_many :people, :through=>:class_assignments
class Person < ActiveRecord::Base
has_many :class_assignments, :dependent => :destroy
has_many :class_rooms, :through=>:class_assignments
class ClassAssignment < ActiveRecord::Base
belongs_to :person
belongs_to :class_room
也就是說,當一個人或一個教室被刪除時,連接表/模型中的記錄也應該被刪除。
但是,ClassRoom.last.destroy
破壞了ClassRoom
,但沒有任何關聯ClassAssignments
。
我知道:dependent=>:destroy
在使用:through
時被忽略,但我應該可以在連接模型上使用它嗎?