如何在活动管理员中将复选框值保存到数据库?

How can i save check boxes value to database in active admin?

我是 rails 上 ruby 的新手并且是活跃的管理员,我需要为注册费创建复选框。当我检查时,复选框中的值未保存到数据库中。谁能帮帮我??

  form do |f|
       f.inputs do
       f.input :name, label: "Student Name"
       f.input :dob,:label => "Date of Birth"
       f.input :age,:label => "Age"
       f.input :gender, as: :radio, :label => "Gender", :collection => [ "Male", "Female"] 
       f.input :reg_fee, :as => :check_boxes, :collection => RegChargeSetup.all.map{|v| ["#{v.reg_fee}"]}
    end
    f.actions
end 

根据您的代码,您正在使用 array of arrays,而您应该使用 array of strings

所以,改变

f.input :reg_fee, :as => :check_boxes, :collection => RegChargeSetup.all.map{|v| ["#{v.reg_fee}"]}

到,

f.input :reg_fee, :as => :check_boxes, :collection => RegChargeSetup.all.map{|v| "#{v.reg_fee}"}



form do |f|
       f.inputs do
       f.input :name, label: "Student Name"
       f.input :dob,:label => "Date of Birth"
       f.input :age,:label => "Age"
       f.input :gender, as: :radio, :label => "Gender", :collection => [ "Male", "Female"] 
       f.input :reg_fee, :as => :check_boxes, :collection => RegChargeSetup.all.map{|v| "#{v.reg_fee}"}
    end
    f.actions
end