retrieving "grandchild" data

This is a classic example of why :through was added to has_many in 1.1 -
see the excellent tutorials at:

Essentially, you add an additional declaration to Library:
has_many :books, :through => :shelves

And then you can say

@books = @library.books

and everything should work normally.

Not sure about the next level (library->shelf->book->page) - any hm:t experts
want to offer some advice?

Max hit the fastest solution on it with find() and :include, but at the
end of the day, these are all Ruby enumerables, so you can fall back
onto Ruby operators (albeit at the cost of more SQL queries):

@pages = { |s| { |b| b.pages } }

Matt Jones wrote: