In my models I use to set a callback to nilify blank json/jsonb values (and the whole column if it's just empty), in the following way:
before_save :nilify_blank_stored_attributes
def nilify_blank_stored_attributes
self.class.stored_attributes.keys.each do |stored_attribute|
send(stored_attribute).delete_if{|k,v| v.blank?}
send(stored_attribute.to_s.concat('=').intern, nil) if send(stored_attribute).empty?
end
end
How about adding this feature?
In my models I use to set a callback to nilify blank json/jsonb values (and the whole column if it's just empty), in the following way:
How about adding this feature?