in the controller: @artists = Artist.find(:all)
in the view:
for artist in @artsists for album in artist.albums ...... end for show in artist.shows ..... end end
in the controller: @artists = Artist.find(:all)
in the view:
for artist in @artsists for album in artist.albums ...... end for show in artist.shows ..... end end
Yes sure, you can pass in conditions to associated models. Try changing the line above to......
for album in artist.albums.find(:all, :order=>"release_date ASC") or for album in artist.albums.find(:all, :order=>"release_date DESC")
depending on which order they need to be in,
Not sure what you mean by that, have you got an example of what you want to produce?
Ok yes. So what you need to do is loop through the albums... Controller: @albums = Album.find(:all, :order=>"release_date ASC")
View: <%for album in @albums%> <%=album.release_date%><br /> <%=album.artist.name%> - <%=album.name%> <%end%>
As you can see because an album belongs to an artist you can access this object with album.artist and then access any attribute within artist - i've guessed at name (album.artist.name)
Ross