@songs = Song.find_by_sql(%Q{
SELECT songs.*, song_playlist_relationships.playlist_id
FROM songs INNER JOIN song_playlist_relationships
ON songs.id = song_playlist_relationships.song_id
WHERE song_playlist_relationships.playlist_id IN
@songs = Song.find_by_sql(%Q{
SELECT songs.*, song_playlist_relationships.playlist_id
FROM songs INNER JOIN song_playlist_relationships
ON songs.id = song_playlist_relationships.song_id
WHERE song_playlist_relationships.playlist_id IN
(#{@playlists.collect{|p| p.id}.join(‘,’)})})
Something like this should work. Double-check the :joins option in the
Rails documentation. I might have it wrong.