I'm storing in my ddbb item configurations in my Campaign model as a jsonb column :items_json. This json will store different products with their own configurations such as color, price, etc.
Is there any approach to edit the jsonb properties (values) from the form_for? I need to be able to iterate through the JSON products and edit their properties individually.
I tried with fields_for with no luck:
<%= form_with(model: [@user,@campaign], url: admin_create_campaign_path, method: :post, local: true) do |form| %>
<%= form.fields_for(:items_json) do |sf| %>
<div class="field">
<%= sf.label :type %>
<%= sf.number_field :type %>
</div>
<div class="field">
<%= sf.label :product %>
</div>
<% end %>
<% end %>
My JSON:
"[{\"type\":\"gift\",\"product\":{\"id\":1157,\"category_id\":12,\"name\":\"Bidón light 550ml\",\"color_attributes\":[\"2E3192\",\"FFFFFF\",\"FF0098\",\"F25A23\",\"1D1D1B\",\"E30713\",\"008D36\"],\"max_printing_colors\":4,\"price\":\"5.61\",\"description\":\"Bidón de aluminio de 550ml de acabado brillo. Disponible en variada gama de colores satinados, libre de BPA. Presentado en atractiva caja de diseño.\\r\\n\\r\\n550 ml\\r\\n\\r\\nAluminio\",\"client_sku\":\"1024.0\",