title: Rails: comparison of Status with Status failed
body: <p>I need to fetch all current_user.friends statuses and then sort them by created_at.</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
   has_many :statuses
  end
  
  class Status &lt; ActiveRecord::Base
   belongs_to :user
  end
  </code></pre>
  
  <p>And in the controller:</p>
  
  <pre><code>def index
      @statuses = []
      current_user.friends.map{ |friend| friend.statuses.each { |status| @statuses &lt;&lt; status } }
      current_user.statuses.each { |status| @statuses &lt;&lt; status }
  
      @statuses.sort! { |a,b| b.created_at &lt;=&gt; a.created_at }
  end
  </code></pre>
  
  <p><code>current_user.friends</code> returns an array of objects <code>User</code></p>
  
  <p><code>friend.statuses</code> returns an array of objects <code>Status</code></p>
  
  <p>Error:</p>
  
  <pre><code>comparison of Status with Status failed
  app/controllers/welcome_controller.rb:10:in `sort!'
  app/controllers/welcome_controller.rb:10:in `index'
  </code></pre>