Hi, im playing around page builder. Modeling Page, PageComponent and Component. I figure out need json column for save custom data for component. But now struggling how to achieve different forms for each component.
Can you point me in the right direction? Thanks!
Hey Diego!
Yep so what I would do is create a migration and set that column as JSONB, it's native to PostgreSQL and is great for storing key-value data.
add_column :customers, :social_links, :jsonb, default:'{}'
With that you'd be able to pull data from customer.social_links['twitter']
Setting this up in a form you would use fields_for. I use SimpleForm but the concept is the same for vanilla Rails.
Gist here:
https://gist.github.com/bearded-avenger/8a16f952e0fe7208912d2f4f8d1d2b49
Does this help?