使用 Audited gem 自动记录到文件
Automatic logging to file with Audited gem
使用 Rails Audited gem,我还希望有一个包含所有更新的友好的、人类可读的日志文件。
有没有办法轻松做到这一点?
您可以利用此选项 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
使用 Rails Audited gem,我还希望有一个包含所有更新的友好的、人类可读的日志文件。
有没有办法轻松做到这一点?
您可以利用此选项 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