Unable to find input class for json - handling JSON type in Active Admin

前端 未结 2 1810
忘了有多久
忘了有多久 2021-02-06 02:24

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
         


        
2条回答
  •  -上瘾入骨i
    2021-02-06 02:58

    This works:

      permit_params :name, {:links => [:facebook, :twitter]}
    
      form do |f|
        f.inputs "Person Details" do
          f.input :name
        end
        f.inputs :name => "Links", :for => :links do |g|
          g.input :facebook, :input_html => { :value => "#{person.links['facebook']}" }
          g.input :twitter, :input_html => { :value => "#{person.links['twitter']}" }
        end
        f.actions
      end
    

    It isn't the nicest solution, but unless someone has a better answer it will have to do.

提交回复
热议问题