I currently have a School model, and a Student model. On Student, I have belongs_to :school, :dependent => destroy.
However, upon deleting a school, the students whose ID is associated with that school are not deleted. In School, I also have has_many :students.
Is there any reason why this is not working? There is a destroy method in the Student model, but it seems like nothing happens to the Student when its School is destroyed. Hoping someone can shed some light on this – perhaps I’m missing something major.
The :dependent option needs to be given for the has_many relationship in the school class…
You will also want to remove the destroy option on your belongs_to association, currently you will delete the associated school record when destroying a student…