Ensure consistent behavior in ActiveRecord::afterSave()

fixes #4012