
Rails gives us some great helpers that save so much time, and you're about to meet one of them: collection checkboxes
We have many playlists, we have many tracks. How do we assign a track to a playlist using our Rails forms? Turns out, it's pretty easy:
<h2 class="text-2xl mt-2">Playlists</h2>
<table>
<%=form.collection_check_boxes(:playlist\_ids, Playlist.all, :id, :name) do |b| %>
<tr>
<td><%= b.check_box %></td>
<td><%= b.label %></td>
</tr>
<% end %>
</table>