rails api 在 heroku 上

rails api on heroku

我使用 rails-api 构建了一个仅 api 的 rails 应用程序。它在本地效果很好。但是,当我将它部署到 heroku 时,它会产生错误 We're sorry, but something went wrong. If you are the application owner check the logs for more information..

然后我在 CLI 中使用命令 heroku logs 检查了日志:

2016-01-26T22:11:39.472621+00:00 app[web.1]: Puma starting in single mode...
2016-01-26T22:11:39.472645+00:00 app[web.1]: * Version 2.15.3 (ruby 2.0.0-p648), codename: Autumn Arbor Airbrush
2016-01-26T22:11:39.472647+00:00 app[web.1]: * Min threads: 5, max threads: 5
2016-01-26T22:11:39.472647+00:00 app[web.1]: * Environment: production
2016-01-26T22:11:40.839892+00:00 app[web.1]: * Listening on tcp://0.0.0.0:12329
2016-01-26T22:11:40.840054+00:00 app[web.1]: Use Ctrl-C to stop
2016-01-26T22:11:40.994291+00:00 heroku[web.1]: State changed from starting to up
2016-01-26T22:11:42.865549+00:00 heroku[router]: at=info method=GET path="/" host=hereze.herokuapp.com request_id=2823dd98-073a-40b5-9faa-1caed3ed263f fwd="89.166.7.101" dyno=web.1 connect=0ms service=38ms status=404 bytes=1744
2016-01-26T22:11:50.101468+00:00 heroku[router]: at=info method=GET path="/reviews" host=hereze.herokuapp.com request_id=2d0d04a6-90c5-4ae7-84a8-2fd1e6287ea3 fwd="89.166.7.101" dyno=web.1 connect=1ms service=16ms status=500 bytes=1669
2016-01-26T22:12:41.819043+00:00 heroku[router]: at=info method=GET path="/reviews" host=hereze.herokuapp.com request_id=854512e4-7a19-4453-9254-2ce09472b5bb fwd="89.166.7.101" dyno=web.1 connect=1ms service=36ms status=500 bytes=1669

但是我在日志中没有看到任何错误,你能帮我解决一下吗?谢谢。

您可以按Cntrl+F 然后搜索错误。您列出的代码不包含任何错误。

但是如果它在本地工作但在 Heroku 中不工作,你可能忘记了 运行

heroku run rake db:migrate

or

heroku run rake db:seed