1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RailsのDeleteメソッドでuninitialized constant Faraday::Error::ConnectionFailed

Posted at

結論、ローカル環境でelasticsearchを起動していないことが原因だった。

スクリーンショット 2021-02-18 19.13.21.png

メソッドとルート

    <%= link_to "削除", "/platforms/#{platform.id}/", method: :delete %>
$ rails routes
                         new_platform GET      /platforms/new(.:format)                                                                 platforms#new
                        edit_platform GET      /platforms/:id/edit(.:format)                                                            platforms#edit
                             platform PATCH    /platforms/:id(.:format)                                                                 platforms#update
                                      PUT      /platforms/:id(.:format)                                                                 platforms#update
                                      DELETE   /platforms/:id(.:format)                                                                 platforms#destroy
                                      GET      /platforms/:id(.:format)                                                                 platforms#show

ルートは正しい(/new/editと違って/destroyや/deleteと誤タイプしないように注意)。

ログを良く見たら、エラーの原因は使っているsearchkickのもととなるelasticsearchを起動していないことが原因だった‥。データが更新されたときに再インデックスが走るようにしていたが、destroyでもこれが呼ばれるために起こったようだ。

> Platform Store (28.3ms)  {"id":138,"exception":["NameError","uninitialized constant Faraday::Error::ConnectionFailed\nDid you mean?  Faraday::ConnectionFailed"],"exception_object":"uninitialized constant Faraday::Error::ConnectionFailed\nDid you mean?  Faraday::ConnectionFailed"}
Completed 500 Internal Server Error in 42ms (Searchkick: 28.3ms | ActiveRecord: 4.7ms | Allocations: 10950)


  
NameError (uninitialized constant Faraday::Error::ConnectionFailed
Did you mean?  Faraday::ConnectionFailed):
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?