# Acts\_as\_mappable :through relationship is not working

**URL:** <https://www.ruby-forum.com/t/acts-as-mappable-through-relationship-is-not-working/166146>\
**Category:** Rails\
**Created:** [April 22, 2009, 9:30am UTC](https://www.ruby-forum.com/t/acts-as-mappable-through-relationship-is-not-working/166146 "2009-04-22T09:30:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 22, 2009, 9:30am UTC](https://www.ruby-forum.com/t/acts-as-mappable-through-relationship-is-not-working/166146/1 "2009-04-22T09:30:45Z")

</div>

Hello-  
I have two models (User and Locations). One user can have multiple  
locations (home, office etc…) The location table has the lat and  
lngs.

class User \< ActiveRecord::Base  
has\_many :locations  
acts\_as\_mappable :through =\> :locations

class Location \< ActiveRecord::Base  
belongs\_to :user  
acts\_as\_mappable

Now, when I do User.find\_within(500. :origin =\> …), It fails with the  
following error:  
Mysql::Error: Unknown column ‘users.lat’ in ‘field  
list’:

So, it seems that the :through relationship is not working. Can  
someone pelase help me.

thanks  
-John

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 22, 2009, 11:18am UTC](https://www.ruby-forum.com/t/acts-as-mappable-through-relationship-is-not-working/166146/2 "2009-04-22T11:18:40Z")

</div>

John,

acts\_as\_mappable is not an association, it’s a custom macro and it  
doesn’t support :through option.

So remove it from the User model. And to find all users near some  
point use something like:

Location.find\_within(500. :origin =\> …, :include =\> :user).map  
(&:user).uniq

Dmitry
