使用Rails 3,我在模型改變了名稱的表像這樣:Rails的 - 改變一個表名,現在測試將不會運行
# app/models/product.rb
class Product < ActiveRecord::Base
set_table_name "items"
end
但是,當我嘗試建立測試,我收到以下錯誤:
Started
E
Finished in 0.027396 seconds.
1) Error:
test_the_truth(CustomerTest):
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'project2_test.products' doesn't exist: DELETE FROM `products`
1 tests, 0 assertions, 0 failures, 1 errors
任何想法如何讓我知道產品?
可能的重複[你如何編寫一個遷移來重命名模型及其在Rails中的表?](http://stackoverflow.com/questions/471416/how-do-you-write-a-migration-to -rename -a-model-and-its-table-in-rails) – Schwern 2012-02-27 02:52:34