retrieve_connection_pool in connection_pool.rb look up connection pool by class name. However, class name is the empty string if the class is created with Class.new(ActiveRecord::Base). If several classes are created that way using different databases, then massive confusion will occur.
I see two possible resolutions to this:
1: Enforce name being != "" when executing estrablish_connection
2: use object_id instead of class name.
Not the biggest issue I guess since it is quite a bit off the normal path of doing things, but it is still not very nice to get silent breakage.
@jonleighton @tenderlove is this a case we want to support?
We use the class name to avoid memory leaks in development mode. I guess a better solution would be to use ActionDispatch::Reloader to clear the cache of the connection handler.
I'm not sure we should be supporting "anonymous" AR classes since a sizable chunk of AR code depends on each class having a proper name (guessing table names, guessing and looking up relation classes, etc).
I agree with @thedarkone
Ya, let's not support anonymous classes for now. I will have people change this to raise an exception.
As long as noone else has to to the error searching I had to do, I'm happy.
I'd prefer if it is kept at a simple check that .name isn't returning the empty string though, since that seems to be the only showstopper.
Anonymous class is not allowed. For reference see #8934 and bc43763
Closing this since #9002 was merged