I'm looking at using the new jsonb capability in Rails4.2 and Postgres4.1.
I was looking at creating a model which represents a user profile (i.e. skill sets, etc) and storing the whole thing in a single jsonb dataset.
So the table would have:
id int
profile jsonb
timestamps
I was thinking I could basically store all the profile data in the jsonb structure as follows (this is just an example/concept):
{
"basics": {
"name": "John Doe",
"label": "Programmer",
"picture": "",
"email": "[email protected]",
"phone": "(912) 555-4321",
"website": "http://johndoe.com",
"summary": "A summary of John Doe...",
"location": {
"address": "2712 Broadway St",
"postalCode": "CA 94115",
"city": "San Francisco",
"countryCode": "US",
"region": "California"
},
"profiles": [{
"network": "Twitter",
"username": "john",
"url": "http://twitter.com/john"
}]
},
"skills": [{
"name": "Web Development",
"level": "Master",
"keywords": [
"HTML",
"CSS",
"Javascript"
]
}],
"languages": [{
"language": "English",
"fluency": "Native speaker"
}],
}
My question is how would I create a basic rails form that would write/read to this structure? I understand how to do it to a traditional relational set of tables, but not sure how to approach when it could all go into a flexible structure like the below?
What would happen at the _form.html.erb and in the controller new/create/edit actions?