At the moment I have three models
A Song has many setlists through Allocations
Allocations belong to Songs and belong to setlists
A setlist has many Songs through Allocations.
Once I’ve created a list the data is displayed in a table with the following link:
<td><%= link_to setlist.date, '#' %></td>
I basically want to have it so that when you click this link, it leads the user to a page where you can select existing songs from the database and add them to the performance list. I’m not entirely sure where to begin as I haven’t had much experience with using has many through relationships, so any pointer in the right direction would be helpful. What should I replace the ‘#’ with? Would it be to a new_allocation_path? Or is there any way of using a nested form so that I can add the songs to the setlists as I create them in the first place?
There’s no single “best” answer here…
The relationship will come into play with how you attach those songs to the setlist. Try to avoid thinking too much about the “through”… and focus on the setlist and song objects.
…but it’s likely that you want to either be on the “show” page for the setlist (with a little form to be able to add songs onto it – a little like the form I’m using now to add an answer to the question).
or…
the “edit” page for the setlist… as some sort of nested form
NB. long form of these is something like