views:

73

answers:

1

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 generates 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?

+1  A: 

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:

  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.
Mike Trpcic
Checking the response code with Firebug (technically the Web Inspector in my case) did the trick. The status code was 405 (Method Not Allowed, very fitting!) so I just made a 405 error page in the public directory. Thank you!
Jimmy Cuadra