79769226

Date: 2025-09-19 07:23:58
Score: 0.5
Natty:
Report link

Here's the recent syntax.

# How to specify particular databases
DatabaseCleaner[:active_record, db: :two]

# You may also pass in the model directly:
DatabaseCleaner[:active_record, db: ModelWithDifferentConnection]

ref: https://github.com/DatabaseCleaner/database_cleaner?tab=readme-ov-file#how-to-use-with-multiple-orms

For me db: :two syntax didn't work, but db: ModelWithDifferentConnection worked as expected.

You can define another Record class and use that as db.

class OtherRecord < ActiveRecord::Base
  self.abstract_class = true

  connects_to database: { writing: :other, reading: :other}
end

# spec/rails_helper.rb hook
DatabaseCleaner[:active_record, db: OtherRecord]
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: foloinfo