我在我的表中添加了一个名为level的新列名为ClassRequest,在localhost上运行了rake db:migrate并且视图工作正常.将更改推送到heroku并且视图遇到错误“NoMethodError:undefined method`level’for#”
所以我运行了heroku run 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:undefined method`level’for#”.
我是铁杆新手所以我不知道什么是错的,也不知道如何检查可能出错的地方.
解决方法
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.