I have a simple “after_filter” that is supposed to remove “child”
records from one table (folders_tbl) when the parent is deleted from
another table (courses_tbl). It’s not working. The “course” gets
destroyed but the children “folders” do not. Filters aren’t that
complicated but I don’t understand why this isn’t working. I’ve
included snipplets below. Any ideas?
–course controller–
after_filter :courseCleanUp, :only => :delete
DELETE /courses/1
def destroy
@course = Course.find(params[:id])
@course.destroy
respond_to do |format|
format.html { redirect_to :action => :index }
end
end
protected
def courseCleanUp
Folder.destroy_all([“course_id = ?”, session[:course_id]])
end