1

I am facing an error when a user enters search string as '%' in url itself. After entering my url looks as

 http://localhost:3000/search/%

Now its showing "NetworkError: 400 Bad Request - http://localhost:3000/search/%". I want to redirect to some other page and show, a bad request image when the error occurs. Please suggest me some ideas to do this.

I have attached the error image. enter image description here

UPDATE

I have tried the below.

config/application.rb:

 config.exceptions_app = self.routes

config/routes.rb:

match "/400", :to => "errors#bad_request"

It's not coming inside the bad_request method.

In Log i am getting error as

 Invalid request: Invalid HTTP format, parsing fails.
Can Can
  • 3,644
  • 5
  • 32
  • 56

1 Answers1

0

Have you checkout this gem 'utf8-cleaner' which removes invalid UTF-8 characters from the environment so that your app doesn't choke on them.

If you want custom error pages: then look at this answer

Community
  • 1
  • 1
Gagan Gami
  • 10,121
  • 1
  • 29
  • 55
  • 1
    Both are not working. First of all the control is not coming to the routes itself. I guess the problem is with thin – Can Can Mar 16 '15 at 06:37