Active record count fix for ruby 4.1.x