katsuo
December 17, 2007, 5:15am
1
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
katsuo
December 17, 2007, 11:18am
2
This is great! Thanks Ryan
katsuo
December 17, 2007, 5:45am
3
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.
katsuo
December 19, 2007, 7:08am
4
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?
katsuo
December 19, 2007, 7:10am
5
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.