5

So, going to http://localhost:3000/%ED will throw ActionController::BadRequest.

But what I really want if return a 404 page (like most websites do).

For instance, Twitter will say:

Invalid Unicode value in one or more parameters /%ED

And me I get that in development (and a 500 error page in production):

going to localhost:3000/%ED

I tried the obvious rescue_from but the error doesn't even it my application as it's raised in the routing stack.

Any idea? I thought about a middleware but doesn't know how I would do it?

Dorian
  • 22,759
  • 8
  • 120
  • 116
  • What you want is to be able to redirect to a 404 page in routes.rb. This might help: http://stackoverflow.com/questions/19653761/how-redirect-to-404-page-in-routes-rb – Ege Ersoz Jul 17 '14 at 16:03
  • Thanks, so I need to use `config.exceptions_app = self.routes`? But then how do I know I got a 404 or a 500? And will it still report the exception? Also, that may be a bad idea, as if there is an error in my application, trying to use my application may generate even more errors? – Dorian Jul 17 '14 at 18:26
  • I added an answer to a similar question here: http://stackoverflow.com/a/26227688/516820 basically I have a middleware that catches the error and returns a `400` error page. – complistic Oct 07 '14 at 05:03
  • I actually found the answer by using utf8-cleaner: http://stackoverflow.com/a/26242215/407213 I recommend it ;) – Dorian Oct 07 '14 at 17:58

1 Answers1

6

I used utf8-cleaner and it works really fine.

Dorian
  • 22,759
  • 8
  • 120
  • 116