ruby-on-rails - 不适用于经过审核的 4.7 gem 更新模型
问题描述
我是 Rails 新手,我使用经过审核的 4.7 gem 用于我的 rails 应用程序来跟踪记录器。我不知道如何向审计表记录添加评论。谢谢你
宝石文件
gem "audited", "~> 4.7"
模型
class Client < ApplicationRecord
audit
解决方案
# 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
推荐阅读
- javascript - 如何使用 puppeteer 检查 div 是否有某个类?
- excel - 在代码执行期间多次使用 Set Worksheets 方法不是一个好主意吗?
- r - RStudio:根据数据表中选择的值过滤数据
- javascript - 为什么数组在 Angular 项目中只带一个对象?
- python-3.x - 为什么我收到请求库错误?
- c - 如何链接到 Visual Studio 2019 中的 ucrt 库?
- python - 匹配零个或一个模式出现
- java - 使用 /src/resources 作为新包的源目录
- android - 我们应该使用 Constraintlayout 作为 Recyclerview 项目布局吗?
- php - Big Sur 并安装 msodbcsql17