Just launched! Get 30% off Rails Revisited Have a Look

Editing Many to Many Records

Buy or Subscribe

You can access this course in just a minute, and support my efforts to rid the world of crappy online courses!

Buy Standalone  Subscribe

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>
    <%=form.collection_check_boxes(:playlist_ids, Playlist.all, :id, :name) do |b| %>
        <td><%= b.check_box %></td>
        <td><%= b.label %></td>
    <% end %>