Issue with dumping active record objects with serialization to YAML and loading them back again

Hello everyone,

While looking around the Rails git repo I found a small bug and when preparing a PR to fix it I think it's a bit more serious than I expected, if someone could take a look and review it it would be nice -> Fixing issue with activerecord serialization not being able to dump a record after loading it from YAML - fixes #13861 by mauricio · Pull Request #13867 · rails/rails · GitHub