Rails 4 Form: has_many through: checkboxes

后端 未结 2 1558
自闭症患者
自闭症患者 2020-12-13 09:25

Original question

Two resources: users and animals. When creating a user, the client selects check boxes to say how many

2条回答
  •  星月不相逢
    2020-12-13 09:55

    collection_check_boxes is a better option:

    <%= f.collection_check_boxes(:animal_ids, Animal.all, :id, :name) do |animal| %>
      <%= animal.label { animal.check_box } %>
    <% end %>
    

提交回复
热议问题