Skip to content

Commit 3e93613

Browse files
committed
Use connection_class to check in connected_to
Rather than check the `connection_specification_name` when determining if we need to stop the user from calling `connected_to`, we can just check the `connection_class?` method which should be `true` for any class which has called `connects_to`.
1 parent 5c24a73 commit 3e93613

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

activerecord/lib/active_record/connection_handling.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def connected_to(role: nil, shard: nil, prevent_writes: false, &blk)
139139
raise NotImplementedError, "calling `connected_to` is only allowed on ActiveRecord::Base or abstract classes."
140140
end
141141

142-
if name != connection_specification_name && !primary_class?
142+
if !connection_class? && !primary_class?
143143
raise NotImplementedError, "calling `connected_to` is only allowed on the abstract class that established the connection."
144144
end
145145

0 commit comments

Comments
 (0)