我是Rails的新手,我在Rails应用程序中使用audited 4.7 gem来跟踪记录器。我不知道如何在审核表记录中添加注释。谢谢
宝石文件
gem "audited", "~> 4.7"
型号
class Client < ApplicationRecord
audit
答案 0 :(得分:1)
# add to your Gemfile, and run bundle install to install it
gem "audited"
# install table for audited gem operation
rails generate audited:install
rails db:migrate
# open your model that you want to audited
class Client < ApplicationRecord
audit
end
# restart rails server
# how to check the action
@client = Client.first
@audits = @client.audits
if @audits
@audits.each do |audit|
if audit.user
audit.user.username
audit.action
end
end
end