0

我是 Rails 新手,我使用经过审核的 4.7 gem 用于我的 rails 应用程序来跟踪记录器。我不知道如何向审计表记录添加评论。谢谢你

宝石文件

gem "audited", "~> 4.7"

模型

class Client < ApplicationRecord

    audit
4

1 回答 1

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
于 2019-02-12T05:49:01.357 回答