Closed newbenji closed 2 years ago
solved it this way for now
but not sure how the restore will react
record: instance.something ? instance.something : {},
Yeah your totally right. Nil should be an accepted value. I can add this soon or will accept a PR if your willing
This is now fixed in 76b6bd9
v0.2.1 is now released which contains this fix.
Actually still get the error with the new version
2: from /home/benji/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/active_snapshot-0.2.1/lib/active_snapshot/models/concerns/snapshots_concern.rb:26:in `create_snapshot!'
1: from /home/benji/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/active_snapshot-0.2.1/lib/active_snapshot/models/concerns/snapshots_concern.rb:26:in `each'
/home/benji/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/active_snapshot-0.2.1/lib/active_snapshot/models/concerns/snapshots_concern.rb:27:in `block in create_snapshot!': undefined method `each' for nil:NilClass (NoMethodError)
this is my json for that part
,
SystemLimit: {
# record: instance.SystemLimit ? instance.SystemLimit : {},
record: instance.SystemLimit,
},
The commented out line is the line working for me
Sorry about that I have now updated the code, tests and released v0.2.2. Please update and that should fix your issue.
if you have in your has_snapshot_children
and for your model
has_one :something
if fails if instance.something = nil for for rails has_one is 0 or 1 item. so should not fail on nil