Open
Description
In a model I have:
field :exclusion, :type => Boolean
...
track_history on: :all, modifier_field_inverse_of: false
When the document is initially created, the exclusion
field doesn’t exist. Later it gets set, and if it’s set to false
, the change isn’t tracked. I’ve tracked things down to line 29 in lib/mongoid/history/attributes/update.rb
:
{ k => format_field(k, v) } unless v.all?(&:blank?)
It’s the v.all
that’s the problem. v
at that point is [nil, false]
, and both nil
and false
are blank?
so it’s not tracking that change. While that’s clearly on purpose it seems wrong. Changing something from non-existent to false
is a change (mongoid thinks so or it wouldn’t be in changes
), so it seems it should be tracked (assuming all other things say it should be tracked). Thoughts?