在Heroku上保存记录或向我的数据库发出POST或DELETE请求时出错。这是我第一次在heroku上部署rails应用程序,我不知道是什么导致了这个问题。我也在网上搜索并阅读了日志,但仍然没有原因。奇怪的是记录得到保存,但它显示了500条消息。
删除方法:
def destroy
if @contact.destroy
flash[:success] = "Successfully deleted contact"
redirect_to root_path
else
flash[:warning] = "Problem encountered while deleting the current contact."
end
end
记录:
2017-08-02T12:29:20.368457 + 00:00 app [web.1]:D, [2017-08-02T12:29:20.368375#4]调试 - : [486f4051-00b0-4d23-8d56-6de722606384](1.5ms)BEGIN 2017-08-02T12:29:20.371200 + 00:00 app [web.1]:D, [2017-08-02T12:29:20.371130#4]调试 - : [486f4051-00b0-4d23-8d56-6de722606384] SQL(1.9ms)DELETE FROM “联系人”WHERE“联系人”。“id”= $ 1 [[“id”,2]] 2017-08-02T12:29:20.374283 + 00:00 app [web.1]:D, [2017-08-02T12:29:20.374212#4]调试 - : [486f4051-00b0-4d23-8d56-6de722606384](2.8ms)COMMIT 2017-08-02T12:29:20.376028 + 00:00 app [web.1]:D, [2017-08-02T12:29:20.375962#4]调试 - : [486f4051-00b0-4d23-8d56-6de722606384]联系删除(1.4ms) {“id”:2,“exception”:[“Faraday :: ConnectionFailed”,“无法打开TCP 连接到localhost:9200(连接被拒绝 - 连接(2)for \“localhost \”端口9200)“],”exception_object“:”无法打开TCP 连接到localhost:9200(连接被拒绝 - 连接(2)for \“localhost \”port 9200)“} 2017-08-02T12:29:20.376531 + 00:00 app [web.1]:我,[2017-08-02T12:29:20.376443#4]信息 - : [486f4051-00b0-4d23-8d56-6de722606384]已完成500内部服务器 错误20ms(Searchkick:1.4ms | ActiveRecord:10.5ms) 2017-08-02T12:29:20.377484 + 00:00 app [web.1]:F, [2017-08-02T12:29:20.377420#4]致命 - : [486f4051-00b0-4d23-8d56-6de722606384] 2017-08-02T12:29:20.377573 + 00:00 app [web.1]:F, [2017-08-02T12:29:20.377489#4]致命 - : [486f4051-00b0-4d23-8d56-6de722606384]法拉第:: ConnectionFailed (无法打开到localhost的TCP连接:9200(连接被拒绝 - connect(2)for“localhost”port 9200)): 2017-08-02T12:29:20.377644 + 00:00 app [web.1]:F, [2017-08-02T12:29:20.377572#4]致命 - : [486f4051-00b0-4d23-8d56-6de722606384] 2017-08-02T12:29:20.377714 + 00:00 app [web.1]:F, [2017-08-02T12:29:10.377644#4]致命 - : [486f4051-00b0-4d23-8d56-6de7226w06384] app / controllers / user / contacts_controller.rb:27:在``destroy' 2017-08-02T12:29:29.530605 + 00:00 heroku [router]:at = info method = GET path =“/ user / contacts”host = hhjjh.herokuapp.com request_id = 62545ba4-c37b-4167-bcf8-24a403638sd0 fwd =“194.201.21.36” dyno = web.1 connect = 1ms service = 17ms status = 200 bytes = 7664 协议= HTTPS
答案 0 :(得分:0)
解决方案是添加heroku提供的elasticsearch插件并重新迁移数据库。谢谢大家:)