You can use joins or includes :
Book.joins(:shelfs) # will load all the Books that have one Shelf
Book.includes(:shelfs) # will load all the Books and Shelfs even if the book has no Shelf associated
# or beginning with a Shelf object:
@shelf.books # will return all Book where shelf_id = @shelf.id
If you need precisions / have questions, don't hesitate to comment ;) (I'm thinking of you phrase "like shelf.books but this won't work if there is need to filter by more than one object." which I don't really understand)