[英]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. 我希望这也会导致
404
或500
错误,以便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: 要解决此问题,您可以执行以下两项操作之一:
GET /posts
, which points to your desired controller. GET /posts
的自定义路由,该路由指向所需的控制器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.