Fix reset_counters crashing on has_many :through associations (3-2-stable branch).

This seems to have been fixed in master ( https://github.com/rails/rails/pull/7822 ), but still is broken in current stable branch.