刪除文章失敗

剛剛想在這裡刪除文章時,出現伍佰了。我立刻下 heroku logs 檢查:

app[web.1]: SQL (2.5ms) (省略) app[web.1]: (0.6ms) ROLLBACK app[web.1]: Completed 500 Internal Server Error in 10ms (ActiveRecord: 5.4ms) app[web.1]: ActiveRecord::InvalidForeignKey (PG::ForeignKeyViolation: ERROR: update or delete on table "articles" violates foreign key constraint "********" on table "article_tags" app[web.1]: DETAIL: Key (id)=(82) is still referenced from table "article_tags".

我一開始以為是 heroku API 有問題,但仔細看,發現「Key (id)=(82) is still referenced from table "article_tags"」:這也就是說,因為文章的一些分類標籤要依賴文章,所以刪不得。

好吧,以後找時間修正。現在先記上一筆。