Forum: Ruby on Rails acts_as_mappable :through relationship is not working

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
john smith (Guest)
on 2009-04-22 11:30
(Received via mailing list)
I have two models (User and Locations). One user can have  multiple
locations (home, office etc..) The location table has the lat and

class User < ActiveRecord::Base
     has_many :locations
     acts_as_mappable :through => :locations

class Location < ActiveRecord::Base
    belongs_to :user

Now, when I do User.find_within(500. :origin => ..), It fails with the
following error:
                Mysql::Error: Unknown column '' in 'field

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

Dmitry S. (Guest)
on 2009-04-22 13:18
(Received via mailing list)

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

This topic is locked and can not be replied to.