diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 9fd29f07..c8cd8a00 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -87,6 +87,7 @@ class ContentController < ApplicationController def edit content_type_class = content_type_from_controller(self.class) @content = content_type_class.find_by(id: params[:id]) + @serialized_content = ContentSerializer.new(@content) if @content.nil? return redirect_to root_path, diff --git a/app/views/content/display/_changelog.html.erb b/app/views/content/display/_changelog.html.erb index 81fe05d0..3834f3ba 100644 --- a/app/views/content/display/_changelog.html.erb +++ b/app/views/content/display/_changelog.html.erb @@ -2,7 +2,8 @@ attribute_change_events = content.raw_model.attribute_change_events content_change_events = content.raw_model.content_change_events - changed_fields = AttributeField.where(id: attribute_change_events.select { |event| event.content_type == 'Attribute' }.map(&:content_id)) + changed_attributes = Attribute.where(id: attribute_change_events.select { |event| event.content_type == 'Attribute' }.map(&:content_id)) + changed_fields = AttributeField.where(id: changed_attributes.pluck(:attribute_field_id)) %> <%# todo full-page changelog with all events %> @@ -28,7 +29,8 @@ <% attribute_change_events.reverse.each do |change_event| %> <% next if change_event.user.nil? %> <% change_event.changed_fields.each do |field_key, change| %> - <% related_field = changed_fields.detect { |field| field.id == change_event.content_id } %> + <% related_attribute = changed_attributes.detect { |attribute| attribute.id == change_event.content_id } %> + <% related_field = changed_fields.detect { |field| field.id == related_attribute.attribute_field_id } %> <% key = related_field.label %> <% next if change.first.blank? && change.second.blank? %> <% next if %w(id created_at updated_at user user_id).include?(field_key) %> diff --git a/app/views/content/display/_sidelinks.html.erb b/app/views/content/display/_sidelinks.html.erb index 9d19fe3f..c73fbd70 100644 --- a/app/views/content/display/_sidelinks.html.erb +++ b/app/views/content/display/_sidelinks.html.erb @@ -12,7 +12,7 @@ <% if creating || editing %>