我想把多个复选框类别[]保存到数据库中:-。
<label><%= f.check_box :category,{class: 'chk'},1,0%>Apple</label>
<label><%= f.check_box :category,{class: 'chk'},1,0%>Orange</label>
<label><%= f.check_box :category,{class: 'chk'},1,0%>Banana</label>
有一个:multiple选项,如果这是你需要的?我很难理解你到底想要什么。
check_box("puppy", "commands", {:multiple => true}, "sit", nil)
check_box("puppy", "commands", {:multiple => true}, "fetch", nil)
check_box("puppy", "commands", {:multiple => true}, "roll_over", nil)
更多的例子在这里。https:/apidock.comrailsActionViewHelpersFormHelpercheck_box。