title: How do I return an object from another model in a scope?
body: <p>I have a <code>Post</code> model, that has the following columns:</p>
  
  <pre><code># == Schema Information
  #
  # Table name: posts
  #
  #  id             :integer          not null, primary key
  #  title          :string(255)
  #  photo          :string(255)
  #  body           :text
  #  created_at     :datetime
  #  updated_at     :datetime
  #  user_id        :integer
  #  ancestry       :string(255)
  #  file           :string(255)
  #  status         :integer          default(0)
  #  slug           :string(255)
  #  is_published   :integer          default(0)
  #  has_eyewitness :boolean          default(FALSE)
  </code></pre>
  
  <p>And a <code>Post belongs_to :user</code>.</p>
  
  <p>What I want to do is create a <code>scope :eyewitness</code> on <code>Post</code>, where whenever <code>has_eyewitness</code> is true, it returns the associated <code>user</code> record.</p>
  
  <p>I tried doing this:</p>
  
  <pre><code>scope :eyewitness, -&gt; { where (has_eyewitness: :true).user }
  </code></pre>
  
  <p>But that gives me all sorts of errors.</p>