我是ruby on rails和active admin的新手,我需要创建注册费复选框。我检查时,复选框中的值未保存到数据库中。任何人都可以帮助我吗?
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
答案 0 :(得分:0)
从您的代码中,您正在使用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