You want to use @playlists.playlists_tracks in your view ...
I think what you need to do is leverage your has_many :through relationship. Something like:
<% for track in @playlist.track_ones %> <tr> <td><%= track.title %></td> </tr> <% end %>
or more idiomatically
<% @playlist.track_ones.each do |track| %> <tr> <td><%= track.title %></td> </tr> <% end %>
I don't know your data model, however, the "track_ones" thing kind of smells a bit of an incorrect data model. In general, if you have a table that enumerates a set of columns (track_1, track_2, ...) it may indicate that you are not modeling a parent -> child relationship. It was just a thought ... I am probably barking up the wrong tree ...
I believe that Rails uses the :source to identify the foreign key in the join table for the :through relationship. Try this ...
class Playlist < ActiveRecord::Base ... has_many :playlists_tracks, :dependent => :destroy has_many :track_ones, :through => :playlists_tracks, :source => :track_one has_many :track_twos, :through => :playlists_tracks, :source => :track_two end
Then use the your :through relationships in the view as before ..
Yes, you're right!
With this model (like you said):
class Playlist < ActiveRecord::Base ... has_many :playlists_tracks, :dependent => :destroy has_many :track_ones, :through => :playlists_tracks, :source => :track_one has_many :track_twos, :through => :playlists_tracks, :source => :track_two end
And this in the playlists/show view:
<% for track_one in @playlist.track_ones %>
<tr> <td><%= track_one.title %></td> </tr>
<% end %>
I can display the track's name.
Bill, Thank you so much! I really appreciate your walking me and my noobishness through this. I can now link the last pieces of my application together, and that's a great relief. Cheers!