# Listing with conditions

**URL:** <https://www.ruby-forum.com/t/listing-with-conditions/125581>\
**Category:** Rails\
**Created:** [January 10, 2008, 10:32am UTC](https://www.ruby-forum.com/t/listing-with-conditions/125581 "2008-01-10T10:32:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![katsuo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@katsuo](https://www.ruby-forum.com/u/katsuo)\
**Post date:** [January 10, 2008, 10:32am UTC](https://www.ruby-forum.com/t/listing-with-conditions/125581/1 "2008-01-10T10:32:53Z")

</div>

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
