问题描述:

# 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

My output:

How do I make the output easier for the end user to read?

网友答案:

The output is from version.changeset, which returns a hash. You can loop through the hash to display each field and its changes on separate lines like so:

%td
  -version.changeset.each do |field, value|
    = field + ": "
    = value
    %br
相关阅读:
Top