On Tuesday, February 17, 2015 at 9:09:57 PM UTC+5:30, Tony Tambe wrote: > > In my music review app the Pins model has attributes of Pin.artist and > Pin.album. I'm trying to list each artist reviewed on the site and which > albums of theirs have been reviewed. Below is what I have so far, but I > want to do it without repeating the artist name. > > Controller: > > @pin_albums = Pin.group(:album).order('artist') > > View: > > <% @pin_albums.each do |pin| %> > <%= pin.artist %> | > <%= link_to pin.album, copy_pin_path(pin) %> > <br/><% end %> > > This lists them like this: > > The Beatles | Let It Be The Beatles | Abbey Road Bob Dylan | Blood On The > Tracks Bob Dylan | Highway 61 Revisited > > I want to list them like so: > > The Beatles | Let It Be > | Abbey RoadBob Dylan | Blood On The Tracks > | Highway 61 Revisited > > I need to do something to the effect of: > > <% @pin_albums.each do |pin| %> > <ul> > <li><%= pin.artist %></li> > <ul> > <% pin.artist.each do |pin_album| %> > <li><%= link_to pin_album.album, pin_album %></li> > <% end %> > <br/><% end %> > > I Think you need something like this <%= form_for @albums do |f| %>
<%= f.fields_for :artist do |r_f| %> ---------do-- <% end %> ------------do-------- <% end %> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/94b0a943-cb9a-459b-8b6d-7988132bddd5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.