mongoid-history
mongoid-history copied to clipboard
Embeds many tracking fails if original value is `nil`
I have a case where I am loading model attributes from YML and the history tracking of an embedded relation was failing on line 93 of update.rb. The value[0]
value is nil
.
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) }
proposed fix...
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) }