Answer the question
In order to leave comments, you need to log in
How to pass input values to Array field of MongoDB in Sinatra using Mongoid?
The view has this code:
%form{"method" => "post", "action" => "/order"}
%input{"name" => "firstname"}
%input{"name" => "order", "value" => "burger", "type" => "checkbox"}
%input{"name" => "order", "value" => "nuggets", "type" => "checkbox"}
%input{"name" => "order", "value" => "mtdew", "type" => "checkbox"}
%input{"type" => "submit"}
post "/order" do
Order.new(
:name => params['name'],
:order => params['order']
).save
end
Answer the question
In order to leave comments, you need to log in
You entered the field name incorrectly. If you require multiple selection, then the field name must end with [] :
...
%input{"name" => "order[]", "value" => "burger", "type" => "checkbox"}
%input{"name" => "order[]", "value" => "nuggets", "type" => "checkbox"}
%input{"name" => "order[]", "value" => "mtdew", "type" => "checkbox"}
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question