Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude Audited Gem Log Entries from PostgreSQL Database Storage #687

Open
hassan-righthand opened this issue Oct 4, 2023 · 0 comments
Open

Comments

@hassan-righthand
Copy link

Issue:
We are currently using the Audited gem to handle audit logs in our Rails application. However, we have a specific use case where we do not want the audit logs generated by Audited to be stored in our PostgreSQL database. Instead, we are using an external source for our audit log storage.

# models/audit.rb
class Audit < Audited::Audit
  before_create :upload_logs
  after_initialize :set_user_details

  def upload_logs
    audit_adapter.upload_logs_to_external_source
  end

  def set_user_details
    audit_adapter.set_user_details
  end

  private

  def audit_adapter
    @audit_adapter ||= AuditAdapter.new(self)
  end
end

In the above code, we have a custom Audit model that inherits from Audited::Audit. We've implemented upload_logs and set_user_details methods to handle the upload of audit logs to an external source and setting user details, respectively.

Expected Outcome:

The goal is to configure Audited in a way that prevents it from storing any data in the PostgreSQL database, ensuring that all audit logs are exclusively stored in our external source.

Additional Context:

  • audited '5.0.2'
  • rails '5.2.8.1'
  • ruby '2.5.1'

Note:

We are seeking guidance on how to configure Audited or if there is a recommended approach to achieve this outcome. Any assistance or suggestions would be greatly appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant