rails/rails — pull request #7660 by senny (2012-09-16 19:52:07+00:00)
Title: log 404 status when ActiveRecord::RecordNotFound was raised (#7646)

As described in #7646 when an ActiveRecord::RecordNotFound was raised rails returned a 404 to the client but logged a status code of 500.

This is a bug fix for the issue described above.

The problem was caused by the following line:
```ruby
status = ActionDispatch::ExceptionWrapper.new({}, payload[:exception]).status_code
```

Since `payload[:exception]` is an Array with two elements: the exception class and the message, the lookup in the `ActionDispatch::ExceptionWrapper` class got confused. The `ExceptionWrapper` used the following lookup machanics:

```ruby
Rack::Utils.status_code(@@rescue_responses[@exception.class.name])
```

which resulted in a lookup for `'Array'` and eventually in a 500.

To fix the bug I did:

* Added a test to `log_subscriber_test` in actionpack (I used a different exception class because `ActiveRecord::RecordNotFound` is not available but they share the same problem)
* Change the lookup in `LogSubscriber` to use the `rescue_responses` hash directly (because I don't have an Exception instance)