LoginSignup
2
0

More than 3 years have passed since last update.

ActionController::UnknownFormatエラーになった時の対処法

Posted at

ActionController::UnknownFormatエラーになった時の対処法

railsでアプリ開発をしている際にでたので自分が行った対処法を書いておきます。
ちなみにnewアクションで投稿機能を実装しようとした時に遭遇しました。
Image from Gyazo

new is missing a templete for this request format and variantとのことです。
newのテンプレートのリクエストフォーマットがミスってる、、、?という低レベルな訳をしたところで、先を読んでいくとあることに気付きました。
次のエラー文request.formats:["text/html"]はrequestはhtmlでそのhtmlがミス(ないよ)っているよということのようです。

new.html.erbを見てみるとファイル名がnew.hml.erbと誤字ってました。
しょうもないミスでしたが、修正すると正常に動作しました。

まとめ

ActionController::UnknownFormatエラーがでた時はビューのファイル名の誤字だったり、ビューが正しい場所にあるか、そもそもビューを作ったかなどを確認すれば大丈夫かと思います。

お役に立ったら幸いです。
最後までご覧いただきありがとうございました。

2
0
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
2
0