0
我是Postgres的新手,在測試博客類型應用程序的銷燬操作時出現此錯誤。看起來問題在於works
而不是work
在給定作者被破壞時被調用 - 因爲它被複數化,但我不確定這是爲什麼。依賴:使用postgresql銷燬拋出錯誤
Author.rb
has_many :works, :dependent => :destroy
錯誤:
AuthorsController::destroy#test_0001_deletes the author:
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column works.author_id does not exist
LINE 1: SELECT "works".* FROM "works" WHERE "works"."author_id" = $...
^
: SELECT "works".* FROM "works" WHERE "works"."author_id" = $1 ORDER BY works.id ASC
測試:
it "deletes the author" do
assert_difference 'Author.count', -1 do
delete :destroy, :id => author.id
end
end
控制器:
def destroy
@author.destroy
redirect_to authors_path
end
就是這樣...感覺有點蠢:p謝謝! – dax