请求格式时,Rails 4 中缺少模板错误 */*;

ben*_*ben 5 format internet-explorer ruby-on-rails actionview

我已经看到这些错误很长时间了,但没有发现问题:

ActionView::MissingTemplate: Missing template pages/home, application/home with {:locale=>[:en], :formats=>["*/*;"]}

用户代理始终是 MSIE6(这是我之前放弃的部分原因)。

重现: curl -H "Accept: */*;" -I http://localhost:5000

有谁知道怎么修?

编辑

curl -H "Accept: */*" -I http://localhost:5000作品。仅当格式设置为*/*;(注意分号)时,它才起作用。

更新

我试图修改Mime:ALL的建议的意见,但无法拥有它同时接受*/*,并*/*;在同一时间。我看到的一个解决方案是在不存在或格式错误的 mime 类型时修补请求的处理方式,但我不确定如何处理。这个答案提供了一个线索,但我仍然没有。

更多更新

我仍然看到这些错误和更多。一个新的是:formats=>["hc/url;*/*"](Firefox)。我很惊讶这不会影响其他任何人,我认为我的代码中没有任何会导致不常见错误的特定内容。

ben*_*ben 1

gregkare刚刚在github上发布了修复程序。

DEFAULT_RESPONSE_FORMAT = :html  
before_filter :set_default_response_format

def set_default_response_format
  request.format = DEFAULT_RESPONSE_FORMAT if request.format.to_sym.nil?
end
Run Code Online (Sandbox Code Playgroud)

不太确定副作用,但目前看来效果很好。