Fix ActiveRecord::ConnectionNotEstablished

[SeeRM #8780]