【问题标题】:rails api on herokuheroku上的rails api
【发布时间】:2016-05-03 16:26:20
【问题描述】:

我使用 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

但我在日志中没有发现任何问题,您能帮帮我吗?谢谢。

【问题讨论】:

  • 这些信息不足以帮助您。我们可以确认 API 返回 500。看看是否有某种方法可以在错误日志中包含更多信息,或者向 Heroku 堆栈添加错误跟踪器。一个常见的原因是运行 heroku run rake db:migrate 失败,试试吧。
  • 查看此答案以了解如何获取有关 500 的更多信息:stackoverflow.com/a/35023278/338536

标签: ruby-on-rails heroku rails-api


【解决方案1】:

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

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

heroku run rake db:migrate

or

heroku run rake db:seed 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-12
    • 2012-09-27
    • 2017-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-06
    相关资源
    最近更新 更多