# GeoKit and Using :through associations

**URL:** <https://www.ruby-forum.com/t/geokit-and-using-through-associations/178053>\
**Category:** Rails\
**Created:** [October 28, 2009, 4:20pm UTC](https://www.ruby-forum.com/t/geokit-and-using-through-associations/178053 "2009-10-28T16:20:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jazcyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@jazcyk](https://www.ruby-forum.com/u/jazcyk)\
**Post date:** [October 28, 2009, 4:20pm UTC](https://www.ruby-forum.com/t/geokit-and-using-through-associations/178053/1 "2009-10-28T16:20:14Z")

</div>

Hi,

I am using Geokit, but I can’t seem to properly limit the number of rows  
returned by GeoKit  
when I do something like this:

Thing.find(:all, :origin =\> [@home\_city.lat, @home\_city.lng], :within =\>  
10, :limit =\> 20)

Thing, actually doesn’t have acts\_as\_mappable set on itself, because  
Thing has a ‘Venue’ relation and it’s that Venue which contains the lat  
and the long. So here is the model for Thing:

belongs\_to :venue  
acts\_as\_mappable :through =\> :venue

And here is Venue:

has\_many :things  
acts\_as\_mappable

But what I think the find command is doing is setting the limit on the  
number of VENUES found, not the total number of THINGs found. Because a  
Venue may have more than one thing, this means I have trouble building  
efficient queries and limiting the records returned. There’s no join  
table involved, even though I’m using :through, and this confuses me a  
little, but I’m assuming that acts\_as\_mappable just absorbs that up.

Any advice on how to fix this little setup? I notice that my has\_many  
and belongs\_to are reversed compared to the Geokit example for :through  
relations… :-/

Thanks for any help offered!

- N

(Disclosure; I posted a similar question to the GeoKit list yesterday  
but no response, so I thought I’d cast a wider net).
