2012-04-25 25 views
6

我添加了一個名爲Level的新列,名爲ClassRequest,運行了一個rake db:在本地主機上遷移並且視圖完美運行。推動對heroku的更改和視圖遇到錯誤「NoMethodError:undefined方法`級別'爲#」成功的heroku運行rake db:遷移但列似乎不工作

因此,我跑了heroku運行rake db:migrate,並且看起來是成功的,顯示下面的代碼。

Running rake db:migrate attached to terminal... up, run.1 
== AddDetailsToClassRequests: migrating ====================================== 
-- add_column(:class_requests, :level, :string) 
    -> 0.0684s 
== AddDetailsToClassRequests: migrated (0.0713s) ============================= 

但是,當我加載關聯的視圖,我仍然有這個錯誤「NoMethodError:未定義的方法`級別爲#」。

我是新來的rails,所以我不知道什麼是錯的,也不知道如何知道如何檢查可能出錯的東西。

回答

12
heroku restart 

檢查Heroku的文檔:https://devcenter.heroku.com/articles/rake

After running a migration you’ll want to restart your app with heroku restart to reload the schema and pickup any schema changes.

+0

工作!非常感謝! – Elisha 2012-04-25 13:28:35

+0

剛剛救了我一把頭髮拉:-) – jflores 2013-02-26 16:34:00

4

你需要你已經運行在遷移後的應用程序重新啓動你。嘗試

heroku restart

,看看情況有所改善。

+0

是的,這工作!謝謝! :) – Elisha 2012-04-25 13:28:55