If a counter_cache is defined, then using update_attributes and changing
the primary key on an association will make sure that the corresponding
counter on the association is changed properly. Fixes #9722.
Merge pull request #9737 from wangjohn/counter_cache_update_attributes_fix

The counter cache will now work correctly when the foreign key is changed. Fixes #9722.