简体   繁体   English

在审核记录中添加自定义属性

[英]Adding Custom Attribute In Audited Record

I want to add custom attributes in the Audit Log like first_name, last_name using audited gem.我想使用审核的 gem 在审核日志中添加自定义属性,例如first_name, last_name My User model contains both attributes but not able to add audit record.我的用户 model 包含这两个属性但无法添加审计记录。

model/audit.rb

class Audit< ActiveRecord::Base
end

I have added first_name and last_name in my migration file我在迁移文件中添加了 first_name 和 last_name

t.column :first_name, :string
t.column :last_name, :string  

It should just work.它应该可以工作。 The audit record doesn't store discrete fields, it stores a YAML or jsonb representation of all changed fields.审计记录不存储离散字段,它存储所有更改字段的 YAML 或 jsonb 表示。 If you've added first_name to your users table, the audit record will automatically note any changes to that attribute.如果您已将 first_name 添加到您的 users 表,审核记录将自动记录对该属性的任何更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM