Listing with conditions

Hi, I am struggling with this problem for a while. I just want to have
books listed according to the title but only one for each title with the
latest volume.

Table for books
id(book_id) series_id volume
1 230 4
2 435 56
3 230 12
4 123 12
5 230 12
6 123 15

Table for series
id(series_id) series_name
123 Lost
230 Mist
435 Dragon Ball

This is what I have so far;

title has_many :books
book belongs_to :title

list_controller
def
@title = Title.find(params[:id])
end

list.rhtml

<% @title.books.each do |book| %> <% end %>
<%= series_name %> <%= book.volume %>

Would like to see a list like this;
Lost 15 #does not show Lost 12
Mist 12 #does not show Mist 4 and other Mist 12
Dragon Ball 56

Please help

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs