Active Admin Formtastic: dynamic has_many inputs without a table?

346 Views Asked by At

I'm using Formtastic as part of Active Admin in Rails

I'd like to use the dynamic form builder (adding and removing elements with buttons). Normally this would be done with has_many inputs, but I am saving to a jsonb array in the database rather than a true has_many relationship

I can set up custom setter methods in the model to accommodate this, but I don't know where to start. I can't use accepts_nested_attributes_for on a jsonb attribute.

In my Active Admin page, if I try to add

f.inputs "General Contact" do
  f.has_many :phone_numbers
...

(where phone_numbers is a jsonb attribute) I get an error

undefined method 'new_record?' for nil:NilClass

Is this possible?

0

There are 0 best solutions below