只是做一些简单的 Ruby on Rails hello world:https://guides.rubyonrails.org/getting_started.html#using-concerns
超级简单,但由于某种原因,我在浏览器中访问 URL http://localhost:3000/articles 时遇到问题。
这是有效的其余客户端调用
Started GET "/articles" for ::1 at 2024-09-19 21:13:06 -0700
Processing by ArticlesController#index as */*
Rendering layout layouts/application.html.erb
Rendering articles/index.html.erb within layouts/application
Rendered articles/index.html.erb within layouts/application (Duration: 0.3ms | GC: 0.0ms)
Rendered layout layouts/application.html.erb (Duration: 300.6ms | GC: 83.0ms)
Completed 200 OK in 305ms (Views: 303.0ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 83.0ms)
这是浏览器调用,但不
Started GET "/articles" for ::1 at 2024-09-19 21:14:13 -0700
Processing by ArticlesController#index as HTML
Rendering public/406-unsupported-browser.html
Rendered public/406-unsupported-browser.html (Duration: 0.5ms | GC: 0.0ms)
Filter chain halted as #<Proc:0x000000010faa86f0 /Users/joe/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/actionpack-7.2.1/lib/action_controller/metal/allow_browser.rb:48 (lambda)> rendered or redirected
Completed 406 Not Acceptable in 5ms (Views: 1.2ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 1.8ms)
我想知道问题是否是
ArticlesController#index as HTML
当我的申请看起来正在返回时 layouts/application.html.erb
我已经尝试过 chrome 和 safari,但没有任何乐趣。烦人的是,如果我将其余客户端响应保存为whatever.html并从chrome打开,它会显示正常。
对于那些遭遇类似命运的人
在应用程序控制器中注释掉允许浏览器现代行就可以了