Basically I have three models songs, playlists and assignments.
Songs have many playlists through assignments, and vice versa.
I want to write a query that finds every playlist that contains a specified song. Let’s say that song is specified by @song.
So far I’ve got:
#find all the assignments that contain a song_id
@commonAssignments = Assignment.where("song_id = ?", @data)
@commonPlaylists = #code to find playlists which contain any of the assignments found here
I was wondering where to go from here, thanks for any help in advance
1 Answer