初心者でもわかるエラー解決-ActionController::UnknownFormat in 〇〇Controller#アクション名

 ActionController::UnknownFormat in 〇〇Controller#アクション名

エラーの本文はこんな感じ。

〇〇Controller#アクション名 is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.

Extracted source (around line #55):
53 "That's what you'll get from an XHR or API request. Give it a shot."
54 raise ActionController::UnknownFormat, message
55 else
56 logger.info "No template found for #{self.class.name}##{action_name},
57 rendering head :no_content" if logger
58 super

○○Controllerの#アクション名でテンプレートがないとなっている

 

解決に繋がる対策:

1、○○Controllerの#アクション名でテンプレートを書き間違えてないか確認する。

2、Gemでインストールをしているのであればサーバー再起動し再確認をする。

🔊gemのインストールを反映するためにサーバーを一度リセットする必要がある。

3、#アクション名ビューの中身に何かを書く。