Automatic logging to file with Audited gem

163 views Asked by At

Using the Rails Audited gem, I would like to also have a friendly, human readable log file that has all the updates.

Is there a way to easily do that?

1

There are 1 answers

3
apneadiving On BEST ANSWER

You could leverage this option from the doc:

class CustomAudit < Audited::Audit
  after_commit :custom_log

  def custom_log
    # do what you need here with attributes
  end
end

# Then set it in an initializer like config/initializers/audited.rb
Audited.config do |config|
  config.audit_class = CustomAudit
end