diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 890681021..5bc869641 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -95,7 +95,7 @@ class Proposal < ApplicationRecord serialize :last_change, coder: YAML serialize :proposal_data, type: Hash, coder: YAML - has_paper_trail only: %i[title abstract details pitch] + has_paper_trail only: %i[title abstract details pitch], versions: { inverse_of: :item } attr_accessor :updating_user attr_writer :tags, :review_tags diff --git a/app/views/staff/proposal_reviews/_reviewer_contents.html.haml b/app/views/staff/proposal_reviews/_reviewer_contents.html.haml index dfb81250a..4c1124dc3 100644 --- a/app/views/staff/proposal_reviews/_reviewer_contents.html.haml +++ b/app/views/staff/proposal_reviews/_reviewer_contents.html.haml @@ -28,9 +28,11 @@ - proposal.versions.each.with_index(1) do |version, index| %details.diff-view{ open: index == proposal.versions.size } %summary= version.created_at.to_fs(:day_at_time) - - version.changeset.each do |k, (old, new)| - %h3.control-label= k.titleize - %div= diff old, new + -# Versions are immutable, so the rendered diff can be cached forever. + - cache version do + - version.changeset.each do |k, (old, new)| + %h3.control-label= k.titleize + %div= diff old, new :css = #{Diffy::CSS}