![](https://bigmachine.io/rails/active_storage/representations/proxy/eyJfcmFpbHMiOnsiZGF0YSI6MTU2LCJwdXIiOiJibG9iX2lkIn19--73436aa24b721b138aea29b75c24268440d5d857/eyJfcmFpbHMiOnsiZGF0YSI6e30sInB1ciI6InZhcmlhdGlvbiJ9fQ==--743878b0228ee81b4587d6ab790a4e67ea599217/rewrite-habtm-form.jpg)
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!
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>