Fix AR serialization

https://github.com/rails/rails/pull/10830