title: Rails: Get Posts of Users within 10km of a point
body: <p>I'm using the rails 3 geokit gem that allows you to find users within a distance of a point, e.g. </p>
  
  <pre><code>User.within(10, origin: [51.123123, 0.1323123])
  </code></pre>
  
  <p>['10' is the distance in mi/km; 51 &amp; 0 are latitude and longitude]</p>
  
  <p>I'm now trying to <strong>get all posts by users who are within a certain distance</strong> of a point. something like:</p>
  
  <pre><code>Post.where(User.within(10, origin: [51.123123, 0.1323123]))
  </code></pre>
  
  <p>(my Post model belongs_to my User model, my User model has_many posts)</p>
  
  <p>Reading around it seems like the solution lies in .where, or using :through &amp; :source, or .joins, but I haven't been able to nail it down.</p>
  
  <p>I'd be very grateful for any help!</p>