Reputation: 81
I know how to make the multi-select form as stated in this documentation. http://www.rubydoc.info/github/justinfrench/formtastic/Formtastic/Inputs/SelectInput
f.input :name, :as => :select, :collection => ["Justin", "Kate"]
It's not clear to me what I had to put inside the permit_params in order for this form request to go through.
I'm doing this through the Company model. So I have
ActiveAdmin.register Company do
permit_params :name
controller do
def create
puts params
company = Company.new(permitted_params[:company])
if company.save
redirect_to admin_companies_path
else
redirect_to new_admin_company_path, alert: 'Please fill all the fields'
end
end
form do |f|
f.inputs do
f.input :name, :as => :select, :collection => ["a","b","c"]
end
end
end
When I submit a form with "b" and "c" selected, i see the following in params[:company]
"company"=>{"name"=>["", "b","c"]}, "commit"=>"Create Company", "controller"=>"admin/companies", "action"=>"create"}
Unpermitted parameter: name
(0.1ms) begin transaction
(0.1ms) rollback transaction
It's not clear to me in the activeadmin, or formtastic documentation, what I need to change in permit_params in order to let this through.
By the way, as you can tell, this is a toy example. After I get this working, I would like to figure out how to do this for a has_many associations. If it's easier to figure out a solution via that path please let me know.
Upvotes: 0
Views: 2020