title: How to Overwrite ActionController::RoutingError on Rails application to catch "bad Ip"
body: <p>I have daily bad request than generates a lot of logs in production.log like this:</p>
  
  <pre><code>F, [2016-02-08T15:39:17.698761 #2437] FATAL -- : 
  ActionController::RoutingError (No route matches [GET] "/sites/default/files/elsevier/eop/S0025-7753(12)00231-X.pdf"):
    actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
    actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call...'
  </code></pre>
  
  <p>In my website there isn't a route for  /sites/`: this is a foreign webservice error, and  I want to know its IP to solve the problem.</p>
  
  <p>I have learned this, but doesn't work and I think I need something else of code</p>
  
  <p>(I have Rails 4.0.2 and I will upgrade to 4.2.5 soon.)</p>
  
  <p>1- In <code>routes.rb</code>, at the end:</p>
  
  <pre><code> match '*path', :to =&gt; 'application#routing_error', via: :all
  </code></pre>
  
  <p>2- In <code>application_ontroller</code>: I log the IP and then <strong>I need to render the 404.html if I'm on production or render the rails error normaly if I'm on development</strong></p>
  
  <pre><code>  def routing_error(error = 'Routing error', status = :not_found, exception=nil)
      logger.debug { "---&gt; I catch you #{request.remote_ip}" }
      render status: 404, file: "404.html"
    end
  </code></pre>