rails/rails — pull request #8547 by printercu (2012-12-18 11:14:18+00:00)
Title: fix for messages in invalid encoding from db-drivers

When postgre query fails it gives sometimes error that could not be converted to utf and app fails with

```
activerecord (3.2.8) lib/active_record/connection_adapters/abstract_adapter.rb:282:in `rescue in log'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:674:in `exec_delete'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/database_statements.rb:96:in `update'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `update'
....
```

`e.message.encode('utf-8')` failed with
```
"\xD0" from ASCII-8BIT to UTF-8
```

I've added explicit `encode()` with `:replace` parameter.