"*!/!*" 不是有效的 MIME 类型

"*!/!*" is not a valid MIME type

自升级到 Rails 6 后,我开始收到此错误:ActionDispatch::Http::MimeNegotiation::InvalidType(“!/!”不是有效的 MIME 类型)。

在回溯中我有

/GEM_ROOT/gems/actionpack-6.1.4.4/lib/action_dispatch/http/mime_negotiation.rb:55 → rescue in block in accepts
/GEM_ROOT/gems/actionpack-6.1.4.4/lib/action_dispatch/http/mime_negotiation.rb:46 → block in accepts
/GEM_ROOT/gems/rack-2.2.3/lib/rack/request.rb:69 → fetch
/GEM_ROOT/gems/rack-2.2.3/lib/rack/request.rb:69 → fetch_header
/GEM_ROOT/gems/actionpack-6.1.4.4/lib/action_dispatch/http/mime_negotiation.rb:45 → accepts
/GEM_ROOT/gems/actionpack-6.1.4.4/lib/action_dispatch/http/mime_negotiation.rb:74 → block in formats
/GEM_ROOT/gems/rack-2.2.3/lib/rack/request.rb:69 → fetch
/GEM_ROOT/gems/rack-2.2.3/lib/rack/request.rb:69 → fetch_header
/GEM_ROOT/gems/actionpack-6.1.4.4/lib/action_dispatch/http/mime_negotiation.rb:70 → formats
/GEM_ROOT/gems/actionpack-6.1.4.4/lib/action_dispatch/http/mime_negotiation.rb:66 → format
/GEM_ROOT/gems/actionpack-6.1.4.4/lib/action_controller/metal/instrumentation.rb:26 → process_action
/GEM_ROOT/gems/actionpack-6.1.4.4/lib/action_controller/metal/params_wrapper.rb:249 → process_action
/GEM_ROOT/gems/activerecord-6.1.4.4/lib/active_record/railties/controller_runtime.rb:27 → process_action
/GEM_ROOT/gems/actionpack-6.1.4.4/lib/abstract_controller/base.rb:165 → process

这个 mime 类型是什么意思?以及如何修复此错误?

它帮助我在 routes.rb 中添加 defaults: { format: 'js' }:

get 'user/card', to: 'user#card', defaults: { format: 'js' }

我在此操作中只有 js 格式供查看。我认为它在类似情况下会有所帮助。