BUGFIX: revision history was messed up when doing quick edits

This commit is contained in:
Régis Hanol 2014-04-30 22:42:56 +02:00
parent dc0a758ec6
commit 02dd80170a

View file

@ -498,7 +498,14 @@ class Post < ActiveRecord::Base
revision = PostRevision.where(post_id: id, number: version).first revision = PostRevision.where(post_id: id, number: version).first
return unless revision return unless revision
revision.user_id = last_editor_id revision.user_id = last_editor_id
revision.modifications = changes.extract!(:raw, :cooked, :edit_reason) modifications = changes.extract!(:raw, :cooked, :edit_reason)
[:raw, :cooked, :edit_reason].each do |field|
if modifications[field].present?
old_value = revision.modifications[field].try(:[], 0) || ""
new_value = modifications[field][1]
revision.modifications[field] = [old_value, new_value]
end
end
revision.save revision.save
end end