简体   繁体   English

Rails ActionController :: MethodNotAllowed导致生产中的WSOD

[英]Rails ActionController::MethodNotAllowed causes WSOD in production

I've got a RESTful resource (let's say posts ) that excludes the index action. 我有一个RESTful资源(比方说posts ),该资源不包括index操作。 When I go to /posts , ActionController::MethodNotAllowed is raised because GET requests at that URL have been excluded. 当我转到/posts ,会引发ActionController::MethodNotAllowed ,因为该URL上的GET请求已被排除。 That much makes sense. 那很有意义。

The problem is that in the production environment, that URL just generates a white screen in the browser. 问题在于,在生产环境中,该URL只会在浏览器中生成白屏。 I can see ActionController::MethodNotAllowed being raised in the production log. 我可以看到在生产日志中引发了ActionController::MethodNotAllowed I would expect that this would also cause a 404 or 500 error so that the error pages in the public directory would serve a pretty error page to the client. 我希望这也会导致404500错误,以便public目录中的错误页面将为客户端提供漂亮的错误页面。

Does this cause a different HTTP status code? 这会导致不同的HTTP状态代码吗? How can I handle this? 我该如何处理?

I'm not positive about what the error might be, but you should get Firebug and check what the HTTP response code coming back is. 我对错误可能是不是很肯定,但是您应该得到Firebug并检查返回的HTTP响应代码是什么。

To get around the issue, you could do one of two things: 要解决此问题,您可以执行以下两项操作之一:

  1. Don't disallow that page in the routes, but have the only code in that method do a redirect to an appropriate page. 不要在路由中禁止该页面,但要使该方法中的唯一代码重定向到适当的页面。
  2. Add a custom route that overrides GET /posts , which points to your desired controller. 添加一个覆盖GET /posts的自定义路由,该路由指向所需的控制器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ActionController :: MethodNotAllowed - ActionController::MethodNotAllowed Rails ActionController :: BadRequest在生产服务器上导致500服务器错误 - Rails ActionController::BadRequest causes 500 Server Error on production server 仅在Rails生产中使用ActionController :: UnknownFormat - ActionController::UnknownFormat in Rails production only 重新加载路由后是否会收到ActionController :: MethodNotAllowed? - ActionController::MethodNotAllowed after reloading routes? Rails 5 ActionController :: InvalidAuthenticityToken on Production Enviroment Nginx - Rails 5 ActionController::InvalidAuthenticityToken on Production Enviroment Nginx 模块中的Rails控制器使用ActionController :: RoutingError(未初始化的常量Admin :: :)在生产中失败 - Rails controllers in modules fail in production with ActionController::RoutingError (uninitialized constant Admin:: ActionController :: MethodNotAllowed(仅允许获取和发布请求。): - ActionController::MethodNotAllowed (Only get and post requests are allowed.): ActionController :: MethodNotAllowed(仅允许获取,放置和删除请求。) - ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.) ActionController :: InvalidAuthenticityToken(ActionController :: InvalidAuthenticityToken):Rails 5 - ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken): Rails 5 生产中的CSRF错误:ActionController :: InvalidCrossOriginRequest - CSRF Error in Production: ActionController::InvalidCrossOriginRequest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM