I was looking for a good way to store user preferences in PostgreSQL, and came across this article on Medium.
store_attributes :preferences do
subscribed_to_newsletter Boolean, default: true
wants_reminders Boolean, default: true
wants_deals_offers Boolean, default: true
end
For the most part this works really well. But now I would like to expand on this and I would like to add in more details.
So in the DB the data is stored in an array...
{
"wants_reminders": true,
"wants_deals_offers": true,
"subscribed_to_newsletter": true
}
But I would like to add another level to this
{
"wants_reminders": true,
"wants_deals_offers": true,
"subscribed_to_newsletter": true,
"Something_here": {
"Option1": "data",
"Option2": "data"
}
}
Does anyone know how I would go about adding in this extra level to the JSON data? Or at least point me to a resource which would help.