1

I am new to ruby on rails and active admin, I need to create check boxes for registration fees. while I checked, the value from checkbox is not saved to the database. can anyone help me ??

  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 
Sravan
  • 18,467
  • 3
  • 30
  • 54

1 Answers1

0

From your code, you are taking array of arrays, instead you should take array of strings,

So, change

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

to,

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 
Sravan
  • 18,467
  • 3
  • 30
  • 54