私は使用simple_form
していて、次のサンプルタグを持っています:
<%= f.input :medical_conditions, :label=>false, :collection => medical_conditons, :as => :check_boxes%>
コレクションには約100個のチェックボックスがあります。ただし、ユーザーが1つまたは2つだけを選択した場合でも、次のようにすべてがデータベースに保存されます。
---
- ""
- ""
- ""
medical_conditions
私の単純な配列ですapplication_helper
def medical_conditons
t = [
"Allergies/Hay Fever",
"Diabetes",
"Heart Surgery"]
return t
end
medical_conditions
フィールドはフィールド:string
です。
選択した値のみがカンマ区切りで保存されるようにするにはどうすればよいですか。