拨开荷叶行,寻梦已然成。仙女莲花里,翩翩白鹭情。
IMG-LOGO
主页 文章列表 "*!/!*"不是有效的MIME型别

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

白鹭 - 2022-02-10 2070 0 0

自从升级到 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 型别是什么意思?以及如何解决这个错误?

uj5u.com热心网友回复:

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

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

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

标签:

0 评论

发表评论

您的电子邮件地址不会被公开。 必填的字段已做标记 *