0
列
我從https://stackoverflow.com/a/4103220/1297435顯示數組
<% Room.all.in_groups_of(1).each do |room_array| %>
<% room_array.each do |room| %>
<%= check_box_tag "student[room_ids][]", room.id, @student.room_ids.include?(room.id), id: dom_id(room) %> <%= label_tag dom_id(room), room.name %><br>
<% end %>
<% end %>
試過當我改變in_groups_of(1)
到in_groups_of(5)
,我得到了錯誤
名爲id的零,這將被錯誤地4 - 如果你真想 的ID爲零,使用object_id
UPDATE
<% Room.all.in_groups_of(5).each do |room_array| %>
<% room_array.compact.each do |room| %>
<%= check_box_tag "student[room_ids][]", room.id, @student.room_ids.include?(room.id), id: dom_id(room) %> <%= label_tag dom_id(room), room.name %><br>
<% end %>
<% end %>
爲什麼不顯示到列?
尼斯,感謝的,但不顯示列,你能幫助我,爲什麼是這樣的http://i.cubeupload.com/vXGixi.png – 2013-04-10 09:59:51