Reputation: 99
Model
# certification.rb
class Certification < ActiveRecord::Base
extend Enumerize
enumerize :certification_type, in: [:SEO, :CRM]
end
My admin file
# admin/certification.rb
ActiveAdmin.register Certification do
permit_params :name,
:certification_type,
form :html => { :enctype => "multipart/form-data" } do |f|
f.inputs "Certifications" do
f.input :name, :label => 'Nom'
f.input :certification_type, :label => 'Type',
as: :check_boxes
end
f.actions
end
end
The problem is with the certification_type
field.
When I tick one type in my activeadmin page, the entry isn't saved in the database. But when I change as: :check_boxes
with a as: :select
, it works.
Do you know if there is a reason ?
Thank you
Upvotes: 1
Views: 838
Reputation: 954
You cannot use checkboxes here, as checkboxes allow to select multiple values for one field, but you didn't specify multiple: true
on the enumerize
(because you don't need this, I guess). So you should use radio buttons, as they allow to select only one of many values (similar to select
).
Try to change as: :check_boxes
to as: :radio
:
f.input :certification_type, :label => 'Type', as: :radio
Upvotes: 3