I have a JSON type in my model, which is coming from Postgres, the migration looks like:
create_table :people do |t|
t.string :name
t.json :links
end
The structure of this JSON object looks like:
{
"facebook" : "u12345",
"google" : "u54321"
}
And in Active Record I am attempting to display this object so that they can be edited, or a new key/value can be added:
form do |f|
f.inputs "Person Details" do
f.input :name
f.input :links <- Error here because active admin doesn't recognise JSON type
end
f.actions
end
When I go to edit a person entry from active admin I get "Unable to find input class for json".
I'd like it so that each key in the json structure becomes a label for an input, e.g:
__________
Facebook | u12345 |
‾‾‾‾‾‾‾‾‾‾
__________
Google | u54321 |
‾‾‾‾‾‾‾‾‾‾
__________
Twitter | |
‾‾‾‾‾‾‾‾‾‾
In my active admin form block I want to specify 3/4 pre-defined keys, say facebook, google, twitter, if one of these keys does not exist in the JSON structure coming from the model, it will be displayed as an empty input, allowing the administrator to add a value to that key, and save it back to the database. If the key does exist in the JSON structure, the input will be populated with its value so that it can be edited.
So my question is how can I simply manage/edit a JSON structure from active admin, and represent the data in the above format?