diff --git a/lib/mongoid/history/attributes/update.rb b/lib/mongoid/history/attributes/update.rb index 3276c8d..5b613e7 100644 --- a/lib/mongoid/history/attributes/update.rb +++ b/lib/mongoid/history/attributes/update.rb @@ -90,7 +90,7 @@ def embeds_many_changes_from_parent(relation, value) relation = trackable_class.database_field_name(relation) relation_class = trackable_class.relation_class_of(relation) paranoia_field = Mongoid::History.trackable_class_settings(relation_class)[:paranoia_field] - original_value = value[0].reject { |rel| rel[paranoia_field].present? } + original_value = (value[0] || []).reject { |rel| rel[paranoia_field].present? } .map { |v_attrs| format_embeds_many_relation(relation, v_attrs) } modified_value = value[1].reject { |rel| rel[paranoia_field].present? } .map { |v_attrs| format_embeds_many_relation(relation, v_attrs) } diff --git a/lib/mongoid/history/tracker.rb b/lib/mongoid/history/tracker.rb index 85d9397..24474bc 100644 --- a/lib/mongoid/history/tracker.rb +++ b/lib/mongoid/history/tracker.rb @@ -95,7 +95,7 @@ def tracked_changes @tracked_changes ||= (modified.keys | original.keys).inject(HashWithIndifferentAccess.new) do |h, k| h[k] = { from: original[k], to: modified[k] }.delete_if { |_, vv| vv.nil? } h - end.delete_if { |k, v| v.blank? || !trackable_parent_class.tracked?(k) } + end.delete_if { |k, v| v.blank? } #|| !trackable_parent_class.tracked?(k) } end # Outputs summary of edit actions performed: :add, :modify, :remove, or :array.