title: Paginate with order defined by joined model in Rails
body: <p>I have currently the following problem in my Rails application (Rails 2.3.5):</p>
  
  <ul>
  <li>I want to sort books stored in the application by the author name, then the title of the book.</li>
  </ul>
  
  <p>Book and Author are concrete models, the corresponding tables are Ressources and People. The relevant portion of the schema is (I have stripped down the model a bit):</p>
  
  <pre><code>  create_table "people", :force =&gt; true do |t|
        t.string   "sur_name"
        t.string   "pre_name"
        ...
        t.string   "type"
      end
  
    create_table "people_ressources", :id =&gt; false, :force =&gt; true do |t|
        t.integer  "ressource_id"
        t.integer  "person_id"
      end
  
    create_table "ressources", :force =&gt; true do |t|
        t.string   "type"
        t.string   "title"
      end
  </code></pre>
  
  <p>To show the list of books, I have used the following paginator:</p>
  
  <pre><code>@books = Book.paginate(
               :order =&gt; 'title', :per_page =&gt; 15, :page =&gt; params[:page])
  </code></pre>
  
  <p>My question now is: How should the paginator be constructed so that the books are ordered not by title, but first by author (== person) sur_name? And if that is not easily reachable, what construct would allow to store books and authors as separate entities, but would allow to get a paginator with the defined order?</p>