Closed razumau closed 2 months ago
Unfortunately, no, models have to have an abstract superclass (like in the examples in the multiple database guide).
The connects_to
method, which handles connections, can only be called on abstract classes and on ActiveRecord::Base
(and will raise an exception otherwise): https://github.com/rails/rails/blob/4fa56814f18fd3da49c83931fa773caa727d8096/activerecord/lib/active_record/connection_handling.rb#L81
It would definitely be simpler for us to mix in database connection details (instead of everything else), but it works like in that in Rails because connections are created and stored wherever this connects_to
method is called (it’s not just “store this connection details for a future call”, it’s actually returning a list of connections). Because they don’t want to create too many connections, connection management is allowed only in a few places.
thx, makes sense :)
you are done here and this should be released as a major change right ?
you are done here and this should be released as a major change right ?
yes
FYI dropping ruby 2.6 and rails 4 too https://github.com/grosser/cia/pull/20 (mostly to avoid sqlite3 version hell)
1.0.0
To work with multiple databases in Active Record (including sharding), models need to inherit from an abstract class layered between it and
ActiveRecord::Base
. We can’t know names of these classes in applications, so instead of loading a completeEvent
andAttributeChange
models, we will now require app developers to create these models themselves.See also a similar recent change in Arturo: https://github.com/zendesk/arturo/pull/133 and https://github.com/zendesk/arturo/pull/138.