Listing items from database with conditions

Hi, I am looking for a way to simplify a listing of books in a database.
I do not want to have all the books listed according to certain title
but just one book with the latest volume even though there are more than
one. Can anyone help me what method or action is needed to accomplish
this task?

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

List on view
Lost 15
Mist 12
Dragon Ball 56

This is great! Thanks Ryan

Book.find_by_title(params[:title], :order => “volume DESC”, :limit => 1)

On Dec 17, 2007 2:45 PM, Katsuo I. [email protected]
wrote:

2 435 56

List on view
Lost 15
Mist 12
Dragon Ball 56

Posted via http://www.ruby-forum.com/.


Ryan B.

Ryan B. wrote:

Book.find_by_title(params[:title], :order => “volume DESC”, :limit => 1)


I’ve created the following method on books.controller and changed series
table to title table

def list
@books = Book.find_by_title(params[:title], :order => “volume DESC”,
:limit => 1)
end

However, got this error message;

“undefined method `find_by_title’ for Book:Class”

Do I have to create find_by_title method on book.rb?

The find_by_title method should be there already, unless you haven’t
changed
the field to title.

On Dec 19, 2007 4:38 PM, Katsuo I. [email protected]
wrote:

@books = Book.find_by_title(params[:title], :order => “volume DESC”,


Ryan B.