title: Using searchlogic to sort associated model's attributes
body: <p>Am using searchlogic for searching, pagination and sorting. My problem lies with sorting.</p>
  
  <p>I have 2 models - submission and person.</p>
  
  <pre><code>class Submission &lt; ActiveRecord::Base
  belongs_to :person
  end
  
  
  class Person &lt; ActiveRecord::Base
   has_many :submissions 
  end
  </code></pre>
  
  <p>In my index.html.erb (for the submission controller), i have the code below for sorting:</p>
  
  <pre><code>&lt;tr&gt;
      &lt;th&gt; &lt;%= order @search, :by =&gt; :SUB_ID, :as =&gt; "Submission Id" %&gt;&lt;/th&gt;
      &lt;th&gt; &lt;%= order @search, :by =&gt; :SUB_ENTRY_DATE, :as =&gt; "Creation Date" %&gt; &lt;/th&gt;
      &lt;th&gt; &lt;%= order @search, :by =&gt; :SUB_TYPE, :as =&gt; "Submission Type" %&gt; &lt;/th&gt;
      &lt;th&gt; &lt;%= order @search, :by =&gt; :PER_NAME??, :as =&gt; "Submitter Name" %&gt; &lt;/th&gt;
  &lt;/tr&gt;
  
  &lt;% @submissions.each do |submission| %&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;%=h submission.SUB_ID %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=h submission.SUB_ENTRY_DATE %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=h submission.SUB_TYPE %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=h submission.person.PER_NAME %&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Sorting the first 3 columns works because those fields are found in the submission table but i don't know how to sort the per_name column.</p>
  
  <p>Thanks a lot for helping me out.</p>