【问题标题】:how to add an active admin field for a postgres jsonb field如何为 postgres jsonb 字段添加活动管理字段
【发布时间】:2016-02-13 08:52:35
【问题描述】:

虽然这适用于 jsonb 字段:

step.title['en'] = 'Lorem'
step.save
step.title
=> {"en"=>"Lorem"}

以下没有

form do |f|
  f.inputs name: 'Title', for: :title do |t|
    t.input :en, input_html: { value: f.object.title['en'] } if f.object.present?
    end
  end
end

根据这个问题重新提问,因为答案似乎不适用于我的情况:Unable to find input class for json - handling JSON type in Active Admin

【问题讨论】:

    标签: ruby-on-rails postgresql activeadmin


    【解决方案1】:

    我使用您原始问题中的链接找到了答案。

    这是我的样子:

    admin/client.rb

    permit_params :name, settings: [ Client.storext_definitions.keys ]
    
    f.inputs name: "Client Settings", for: :settings do |s|
      s.input :status_for_map, as: :select, collection: options_for_select( Order.statuses.map{ |status, id| [status.humanize, status] }, client.settings['status_for_map'])
      s.input :time_zone, input_html: { value: "#{client.settings['time_zone']}" }
    end
    

    希望对您或任何跟进的人有所帮助。

    【讨论】:

      猜你喜欢
      • 2023-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-14
      • 2015-10-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多