Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Make all models not_sharded by default #170

@bogdan

Description

@bogdan

I am trying to make all my models not sharded by default with.

But it results in a weird behavior. on_shard call doesn't establish connection to shard because connection_specification_name calls is_sharded? on ActiveRecord::Base which is false.

The following code results in AR::ConnectionNotEstablished:

ActiveRecord::Base.not_sharded
class Visitor < ActiveRecord::Base
  self.sharded = true
end

ActiveRecord::Base.on_shard(1) do
 Visitor.first
end

While the following would work:

Visitor.on_shard(1) do
 Visitor.first
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions