I have a problem with a simple_form_for, if I select many number in my form, I have a rollback, it is not possible to validate.
I have this error:
Processing by SudokusController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Qafet...", "sudoku"=>{"number"=>"1, 2"}, "commit"=>"Submit"}
but in Terminal (rails c) it's work....
I can not solved this:
_form.html.erb:
<%= simple_form_for @sudoku do |f| %>
<% (1..9).each do |x| %>
<div class="checkbox">
<label>
<input type="checkbox"name="sudoku[number[]"id="optionsRadios<%= x %>" value="<%= x %>" />
<%= x %>
</label>
</div>
<% end %>
<% end %>
sudoku.rb:
validates :number, presence: true
in sudoku controller:
def sudoku_params
params.require(:sudoku).permit(:number)
end
In my db
Sudoku (number:string)
Tanks for your help
Aucun commentaire:
Enregistrer un commentaire