Using Rails 6 Multi-database with audited gem

45 Views Asked by At

How can I use the Rails 6 Multi-db functionalities with the audited gem?

I tried to use connects_to in my Audit model, but that does not seem to work:

class ExtendAudit < Audited::Audit
  connects_to database: { writing: :secondary, reading: :secondary }

  before_save do
    self.source = ::Audited.store[:app_source]
    self.change_audit_changes
    self.abort_saving
    self.change_username
  end
....

The error I get is that in 'connects_to': 'connects_to' can only be called on ActiveRecord::Base or abstract classes (NotImplementedError)

From what I've seen, the Audit class does implement the ActiveRecord::Base.

Do you have any thoughts on this?

0

There are 0 best solutions below