Rescue an ActionController::BadRequest

后端 未结 1 659
无人及你
无人及你 2021-02-09 05:12

I am running a rails app and I have a simple show action, where the code is something like the following:

@post = Post.find(params[:id])

So if

相关标签:
1条回答
  • 2021-02-09 05:56

    OK I found that if you pass something like %ED it is a 400 bad request so I just created a 400 static page and I've added the following in my exception notification:

      Myapp::Application.config.middleware.use ExceptionNotification::Rack,
      :ignore_exceptions => ['ActionController::BadRequest'] + ExceptionNotifier.ignored_exceptions,
      :ignore_crawlers => %w{Googlebot bingbot},
      :email => {
        :email_prefix => "[Myapp.com Exception Notifier] ",
        :sender_address => %{"myapp.com" <info@myapp.com>},
        :exception_recipients => %w{myemail@myapp.com}
      }
    
    0 讨论(0)
提交回复
热议问题