簡體   English   中英

ActiveRecord :: StatementInvalid:找不到表

[英]ActiveRecord::StatementInvalid: Could not find table

我正在嘗試運行users_test.rb文件

test "the truth" do
     assert true
   end

我確實有一個喜歡的桌子,我仍然得到這個錯誤。 為什么這樣?

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
➜  channelappnew  rake db:test:clone
➜  channelappnew  rake db:test:clone_structure
➜  channelappnew  rake db:migrate
➜  channelappnew  rake db:test:load
➜  channelappnew  rake db:test:prepare
➜  channelappnew  rake db:test:purge
➜  channelappnew  ruby -Itest test/unit/user_test.rb
Loaded suite test/unit/user_test
Started
E

Error:
test_the_truth(UserTest):
ActiveRecord::StatementInvalid: Could not find table 'likes'




Finished in 0.058371 seconds.

1 tests, 0 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
0% passed

17.13 tests/s, 0.00 assertions/s

謝謝!

在測試之前做rake db:test:prepare

你運行rake db:migrate嗎? 如果表存在,請檢查數據庫。 如果您正在使用sqlite,則調用sqlite3 db/development.sqlite3然后發出命令.schema您可以手動刪除數據庫db/test.sqlite3 ,然后使用rake db:setup重新創建它。

有時它是由多個版本的活動記錄寶石引起的。 請卸載除您的應用程序正在使用的寶石之外的所有寶石。 我遇到了同樣的問題,做了我說的話。 有效。

你檢查過你的燈具了嗎? 我碰巧修改了一個遷移但是夾具固定不變,因此導致了錯誤。

我剛遇到同樣的問題,並在db / schema.rb中找到了解決方案:

# Could not dump table "xxx" because of following StandardError
#   Unknown type 'bool' for column 'yyy'

也許這有幫助!

除了這個schema.rb之外,“bool”在所有地方工作,但是在開發模式下正確執行的遷移。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM