![]() |
新品価格 |
Railsで以下のエラーが度々出てた
ActionController::UnknownFormat (AAAController#aaa is missing a template for this request format and variant.
これの解決策
・再現手順
再現手順がさっぱり分からなかったのですが
以下で再現しました
1 | curl URL -H "Accept:存在しないヘッダ" |
Acceptヘッダは受け取れるヘッダを指定するものらしい
https://developer.mozilla.org/ja/docs/Web/HTTP/Headers/Accept
・解決策
1 2 3 4 5 6 7 | class A rescue_from ActionController::UnknownFormat, with: :rescue406 def rescue406(e) #エラーの時の内容 end end |
https://qiita.com/kazutosato/items/ffceb94b136f69563beb
こうしてエラーを解消できましたとさ
長年のエラーが解決してよかった