airrecord
airrecord copied to clipboard
Fails to update multi-select fields.
I have a multi-select field that has options: Yes, No, Confirmed.
The field is set to ["Yes"], and I want to be set to ["Yes", "Confirmed"]
I found that I can't just add one - I have to clear it first. So instead of:
contact["Next delivery"].push("Confirmed")
contact.save
I have to do:
result = contact["Next delivery"].push("Confirmed")
contact["Next delivery"] = []
contact["Next delivery"] = result
contact.save
Please consider submitting a patch
I looked at this briefly and it stems from the way that changes are tracked based on using the =
setter method. Making changes directly to an array field doesn't use this method so the @updated_keys
value is never changed. I don't see a quick/easy way to solve this.
https://github.com/sirupsen/airrecord/blob/f2bf601a35c52cd62525830b14afcd2dbe18caed/lib/airrecord/table.rb#L125-L130
@mbreen you could simplify your code a bit. You don't need to clear out the existing value, you just need to overwrite it with a new array:
contact["Next delivery"] += ["Confirmed"]
=> ["Yes", "Confirmed"]
contact.save