gpt4 book ai didi

ruby-on-rails - 如何在 View 中使用 paper_trail 格式化变更集的输出?

转载 作者:数据小太阳 更新时间:2023-10-29 09:02:09 25 4
gpt4 key购买 nike

# reports\workorder_version.html.haml
%table
%class='Work Orders'
%tr
%thead
%tr
%th Index
%th Date
%th User ID
%th Event
%th Item Type
%th Item ID
%th Change Set
%th IP Address
%tr

%tbody
- workorder = Workorder.where(:id => params[:id]).first
- workorder.versions.reverse.each do |version|
%tr
%td= version.index
%td= version.created_at.in_time_zone('Eastern Time (US & Canada)')
%td= Employee.find(version.whodunnit.to_i).full_name.upcase
%td= version.event.humanize
%td= version.item_type.humanize
%td= version.item_id
%td= version.changeset.to_s.humanize
%td= version.ip

我的输出:

Output of my report[1]

如何让最终用户更容易阅读输出?

最佳答案

输出来自version.changeset, which returns a hash .您可以遍历散列以在单独的行上显示每个字段及其更改,如下所示:

%td
-version.changeset.each do |field, value|
= field + ": "
= value
%br

关于ruby-on-rails - 如何在 View 中使用 paper_trail 格式化变更集的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33023254/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com