-
Notifications
You must be signed in to change notification settings - Fork 180
Open
Description
In my instance I had issues parsing the meta attributes in edit page.
undefined method `each' for "{}":String
I fixed that by using:
diff --git a/app/views/shared/_meta_form.html.haml b/app/views/shared/_meta_form.html.haml
index 00d8c0c..7c7847f 100644
--- a/app/views/shared/_meta_form.html.haml
+++ b/app/views/shared/_meta_form.html.haml
@@ -1,5 +1,15 @@
+- require 'json'
#js-meta-table.invoice-table
- - instance.meta.each do |key, value|
+ - meta_data = {}
+ - if instance.meta.is_a?(String) && !instance.meta.empty?
+ - begin
+ - # Convert Ruby hash string to valid JSON format
+ - valid_json = instance.meta.gsub("=>", ":").gsub(/(['"])(.*?)\1/, '"\2"')
+ - meta_data = JSON.parse(valid_json) rescue {}
+ - rescue JSON::ParserError => e
+ %p Error parsing JSON: #{e.message}
+
+ - meta_data.each do |key, value|
.invoice-row.js-meta
.invoice-col.form-group
= text_field :key, "", value: key, class: 'form-control', placeholder: "Key"
Metadata
Metadata
Assignees
Labels
No labels