Searchlogic on associations <p>I have the following associations:</p> <pre><code>class BookShelf { has_many :books } class Book { has_many :pages belongs_to :book_shelf } class Page { belongs_to :book } </code></pre> <p>If I have a BookShelf object, how could I use searchlogic to search pages that belong to the books in the current book shelf?</p> <p>Currently I'm using this one:</p> <pre><code>@bookshelf = BookShelf.find 1 @pages = Page.title_like("something").book_id_equals(@bookshelf.books.map { |book| book.id }).paginate :page =&gt; params[:page] </code></pre> <p>So the paginate part is just the use of will_paginate which is not really relavent.</p> <p>The point is I think these lines of codes are somewhat ugly. Is there any improvements?</p>