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