The problem that we remove all nil values before pushing data to Fortnox. In this case it means we are removing all values and sends an empty object to Fortnox.
We can catch this error. The problem in my opinion is updated_customer.saved? => false.
The to_hash function removes nil values and we are also removing nil values when we are creating the new_hash, but we are allowing nil values as input in the hash argument. We could easily just delete the nil values from new_attributes before comparing it to old_attributes to avoid this problem. Then this method would return self, which would result in updated_customer.saved? => true meaning no request will be made.
This flow currently leads to a strange bug:
The request body to Fortnox looks like this:
The problem that we remove all
nil
values before pushing data to Fortnox. In this case it means we are removing all values and sends an empty object to Fortnox.We can catch this error. The problem in my opinion is
updated_customer.saved? => false
.This is the update method:
The
to_hash
function removesnil
values and we are also removingnil
values when we are creating thenew_hash
, but we are allowingnil
values as input in thehash
argument. We could easily just delete the nil values fromnew_attributes
before comparing it toold_attributes
to avoid this problem. Then this method would returnself
, which would result inupdated_customer.saved? => true
meaning no request will be made.