I've got a RESTful resource (let's say posts
) that excludes the index
action. When I go to /posts
, ActionController::MethodNotAllowed
is raised because GET
requests at that URL have been excluded. That much makes sense.
The problem is that in the production environment, that URL just g开发者_开发知识库enerates a white screen in the browser. I can see ActionController::MethodNotAllowed
being raised in the production log. 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.
Does this cause a different HTTP status code? 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.
To get around the issue, you could do one of two things:
- Don't disallow that page in the routes, but have the only code in that method do a redirect to an appropriate page.
- Add a custom route that overrides
GET /posts
, which points to your desired controller.
精彩评论